小编CS *_*wis的帖子

修改了什么步骤摆脱了Collection; 枚举操作可能无法执行.错误?

我们的编程涉及使用内存数据进行的一些Mock测试.因此,我们实现了以下代码,该代码首先创建Customer对象的内存数据

        // Let us create some in-memory data
        // Create a list of Customer
        List<Customer> listOfCustomers =  new List<BlahBlahExample.Domain.Objects.Customer>()
                                   { new Customer { CustomerID = "1    ",Orders = new HashSet<Order>(), CustomerDemographics = new HashSet<CustomerDemographic>(), CompanyName = "Chicago Bulls", ContactName = "Michael Jordan", ContactTitle = "top basket ball player", Address = "332 testing lane", City = "Chicago", Region = "Illinois", PostalCode = "484894", Country = "USA", Phone = "3293993", Fax = "39393" },
                                     new Customer { CustomerID = "2    ",Orders = …
Run Code Online (Sandbox Code Playgroud)

unit-testing entity-framework moq mocking dbset

6
推荐指数
2
解决办法
1422
查看次数

如何配置PhantomJSDriver以尽可能地模拟我的Google Chrome浏览器?

以下是我的开发环境的详细信息:

-Visual Studio 2012 Ultimate与更新4

-Google Chrome版本40.0.2214.94 m

-Windows 7 Professional,具有32位操作系统

我的Google Chrome浏览器的用户代理字符串是:

Mozilla/5.0(Windows NT 6.1)AppleWebKit/537.36(KHTML,与Gecko一样)Chrome/40.0.2214.94 Safari/537.36

我的Automated UI测试代码中的C#代码如下:

var options = new PhantomJSOptions();

// Chrome User Agent ( Chrome Version 40.0.2214.94 m ) 
options.AddAdditionalCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36");

driver = new OpenQA.Selenium.PhantomJS.PhantomJSDriver(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\packages\PhantomJS.1.9.8\tools\phantomjs"), options);

url = new Uri("http://localhost:2816/");

IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(90.00));

wait.Until(ExpectedConditions.ElementIsClickable( By.XPath("//a[text()='Users']")));

IWebElement btn = waitArg.Until<IWebElement>((d) => {
 try{ 
 return d.FindElement( By.XPath("//a[text()='Users']") );
 }
 catch {

        return null;
    } …
Run Code Online (Sandbox Code Playgroud)

c# configuration phantomjs selenium-webdriver

4
推荐指数
1
解决办法
6463
查看次数

在没有实际的 SQL Server 数据库启动和运行的情况下,我将如何配置工作量测试工具来模拟实体框架的 DbContext?

我们团队的应用程序开发涉及使用工作量测试工具来模拟我们的实体框架的 DbContext。然而,工作量测试工具似乎需要查看应用程序使用的实际 SQL Server 数据库,以便模拟我们的实体框架的 DbContext,这似乎违反了正确的单元测试原则。

原因是,为了通过模拟与数据库连接相关的任何内容(例如实体框架的 DbContext)来对我们的应用程序代码进行单元测试,我们永远不需要启动并运行数据库。

在没有实际的 SQL Server 数据库启动和运行的情况下,我将如何配置工作量测试工具来模拟实体框架的 DbContext?

* 更新:

@gert-arnold 我们正在使用实体框架模型优先方法来实现后端模型和数据库。

以下摘自测试代码:

        connection = Effort.EntityConnectionFactory.CreateTransient("name=NorthwindModel");
        jsAudtMppngPrvdr = new BlahBlahAuditMappingProvider();
        fctry = new BlahBlahDataContext(jsAudtMppngPrvdr, connection, false);
        qryCtxt = new BlahBlahDataContext(connection, false);
        audtCtxt = new BlahBlahAuditContext(connection, false);
        mockedReptryCtxt = new BlahBlahDataContext(connection, false);
        _repository = fctry.CreateRepository<Account>(mockedReptryCtxt, null);
        _repositoryAccountRoleMaps = fctry.CreateRepository<AccountRoleMap>(null, _repository);
Run Code Online (Sandbox Code Playgroud)

“name=NorthwindModel”与我们的 edmx 文件相关,其中包含有关数据库表及其相应关系的信息。

如果我通过像下面的代码行那样建立连接来删除“name=NorthwindModel”,则会收到一条错误消息,指出它需要一个参数:

   connection = Effort.EntityConnectionFactory.CreateTransient(); // throws error
Run Code Online (Sandbox Code Playgroud)

您能解释一下上述代码应该如何重写吗?

sql-server unit-testing entity-framework mocking effort

2
推荐指数
1
解决办法
2957
查看次数

如何使用JSON.NET创建具有嵌套数组值的JSON String?

感谢@ don-jayamanne和@dbc提到我的JSON需要格式良好

这是我的改述问题:

我们的工作应用程序是使用JSON.NET来创建JSON字符串.

这是我正在尝试创建的JSON字符串:

{
    "RouteID": "123321213312",
    "DriverName": "JohnDoe",
    "Shift": "Night",
    "ItineraryCoordinates": [
        [
            9393,
            4443
        ],
        [
            8832,
            3322
        ],
        [
            223,
            3432
        ],
        [
            223,
            3432
        ]
    ]
}
Run Code Online (Sandbox Code Playgroud)

这是我编写的用于创建上述JSON字符串的错误代码:

writer.WriteStartObject();
writer.WritePropertyName("RouteID");
serializer.Serialize(writer, routeID);

writer.WritePropertyName("DriverName");
serializer.Serialize(writer, driverName);

writer.WritePropertyName("Shift");
serializer.Serialize(writer, shift);

writer.WritePropertyName("ItineraryCoordinates");

ItineraryCoordinatesCollectionFactory tpCollFac = new ItineraryCoordinatesCollectionFactory();
ItineraryCoordinates anItineraryCoordinates;

StringBuilder coordSB = new StringBuilder();

IList<TimePeriod> ItineraryCoordinatesCollection = tpCollFac.createItineraryCoordinatesCollection();
for (int j = 0; j < ItineraryCoordinatesCollection.Count(); j++)
{
    anItineraryCoordinates = ItineraryCoordinatesCollection[j];

    writer.WriteStartObject();
    writer.WritePropertyName("nested");
    coordSB.Append(anItineraryCoordinates.StartTimePeriodCoordinate.X.ToString());
    coordSB.Append(" , ");
    coordSB.Append(anItineraryCoordinates.StartTimePeriodCoordinate.Y.ToString()); …
Run Code Online (Sandbox Code Playgroud)

c# json nested json.net converters

1
推荐指数
1
解决办法
4362
查看次数

如何在Visual Studio Online中的托管构建代理上安装SQL Server?

我们的一位客户使用基于Team Foundation Server(TFS)功能的Visual Studio Online(http://www.visualstudio.com/en-us/products/what-is-visual-studio-online-vs.aspx) )

我们正在研究如何使用Visual Studio Online帐户进行自动构建和自动化单元测试.

使用Visual Studio 2012 IDE,我能够在Hosted Build Service中设置构建.但是,我的单元测试需要一个Microsoft SQL Server数据库才能正常运行,我已经在我的开发工作站上安装了它.

为了运行我的测试,我需要让我的数据库在构建代理上的SQL实例中运行.

是否可以在Hosted Build Agent上安装SQL Server,如果可以,如何安装?

sql-server tfs unit-testing tfsbuild azure-devops

0
推荐指数
1
解决办法
1269
查看次数