本文整理汇总了C#中TrackableEntities.Client.Tests.Entities.Mocks.MockNorthwind类的典型用法代码示例。如果您正苦于以下问题:C# MockNorthwind类的具体用法?C# MockNorthwind怎么用?C# MockNorthwind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockNorthwind类属于TrackableEntities.Client.Tests.Entities.Mocks命名空间,在下文中一共展示了MockNorthwind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Existing_Parent_With_Added_Children_Should_Have_Children_Marked_As_Added
public void Existing_Parent_With_Added_Children_Should_Have_Children_Marked_As_Added()
{
// Arrange
var database = new MockNorthwind();
var order = database.Orders[0];
var changeTracker = new ChangeTrackingCollection<Order>(order);
var orderDetails = (IList<OrderDetail>)changeTracker[0].OrderDetails;
var addedDetail1 = new OrderDetail
{
ProductId = 1,
Product = database.Products[0],
Quantity = 10,
UnitPrice = 20M
};
var addedDetail2 = new OrderDetail
{
ProductId = 2,
Product = database.Products[1],
Quantity = 20,
UnitPrice = 30M
};
// Act
orderDetails.Add(addedDetail1);
orderDetails.Add(addedDetail2);
// Assert
Assert.Equal(TrackingState.Added, addedDetail1.TrackingState);
Assert.Equal(TrackingState.Added, addedDetail2.TrackingState);
}
示例2: Existing_Parent_With_Children_Should_Have_Children_Marked
public void Existing_Parent_With_Children_Should_Have_Children_Marked()
{
// Arrange
var database = new MockNorthwind();
var order = database.Orders[0];
var changeTracker = new ChangeTrackingCollection<Order>(order);
var orderDetails = (IList<OrderDetail>)changeTracker[0].OrderDetails;
var addedDetail = new OrderDetail
{
ProductId = 1,
Product = database.Products[0],
Quantity = 10,
UnitPrice = 20M
};
var modifiedDetail = orderDetails[0];
var deletedDetail = orderDetails[1];
addedDetail.Order = order;
modifiedDetail.Order = order;
deletedDetail.Order = order;
// Act
modifiedDetail.UnitPrice++;
orderDetails.Remove(deletedDetail);
orderDetails.Add(addedDetail);
// Assert
Assert.Equal(TrackingState.Added, addedDetail.TrackingState);
Assert.Equal(TrackingState.Modified, modifiedDetail.TrackingState);
Assert.Equal(TrackingState.Deleted, deletedDetail.TrackingState);
}
示例3: Items_Should_Be_Added_As_Unchanged_With_Array_Ctor
public void Items_Should_Be_Added_As_Unchanged_With_Array_Ctor()
{
// Arrange
var database = new MockNorthwind();
var product = database.Products[0];
// Act
var changeTracker = new ChangeTrackingCollection<Product>(product);
// Assert
Assert.AreEqual(TrackingState.Unchanged, changeTracker[0].TrackingState);
}
示例4: Tracking_Should_Be_Enabled_With_Array_Ctor
public void Tracking_Should_Be_Enabled_With_Array_Ctor()
{
// Arrange
var database = new MockNorthwind();
var product = database.Products[1];
// Act
var changeTracker = new ChangeTrackingCollection<Product>(database.Products[0]);
changeTracker.Add(product);
// Assert
Assert.AreEqual(TrackingState.Added, changeTracker[1].TrackingState);
}
示例5: Tracking_Should_Be_Disabled_With_Default_Ctor
public void Tracking_Should_Be_Disabled_With_Default_Ctor()
{
// Arrange
var database = new MockNorthwind();
var product = database.Products[0];
var changeTracker = new ChangeTrackingCollection<Product>();
// Act
changeTracker.Add(product);
// Assert
Assert.AreEqual(TrackingState.Unchanged, changeTracker[0].TrackingState);
}
示例6: Added_Parent_With_Children_Should_Have_Children_Marked_As_Added
public void Added_Parent_With_Children_Should_Have_Children_Marked_As_Added()
{
// Arrange
var database = new MockNorthwind();
var changeTracker = new ChangeTrackingCollection<Order>(true);
var order = database.Orders[0];
var orderDetails = (IList<OrderDetail>)order.OrderDetails;
// Act
changeTracker.Add(order);
// Assert
Assert.Equal(TrackingState.Added, order.TrackingState);
Assert.Equal(TrackingState.Added, orderDetails[0].TrackingState);
}
示例7: MergeChanges_Should_Set_ModifiedProperties_To_Null_For_Modified_Order_With_Updated_Customer
public void MergeChanges_Should_Set_ModifiedProperties_To_Null_For_Modified_Order_With_Updated_Customer()
{
// Arrange
var database = new MockNorthwind();
var origOrder = database.Orders[0];
var changeTracker = new ChangeTrackingCollection<Order>(origOrder);
origOrder.CustomerId = "ALFKI";
var origModifiedProps = origOrder.ModifiedProperties;
var updatedOrder = UpdateOrders(database, origOrder)[0];
// Act
changeTracker.MergeChanges(updatedOrder);
// Assert
Assert.Contains("CustomerId", origModifiedProps);
Assert.Null(origOrder.ModifiedProperties);
}
示例8: MergeChanges_Should_Set_TrackingState_To_Unchanged_For_Modified_Order_With_Updated_Customer
public void MergeChanges_Should_Set_TrackingState_To_Unchanged_For_Modified_Order_With_Updated_Customer()
{
// Arrange
var database = new MockNorthwind();
var origOrder = database.Orders[0];
var changeTracker = new ChangeTrackingCollection<Order>(origOrder);
origOrder.CustomerId = "ALFKI";
TrackingState origTrackingState = origOrder.TrackingState;
var updatedOrder = UpdateOrders(database, origOrder)[0];
// Act
changeTracker.MergeChanges(updatedOrder);
// Assert
Assert.Equal(TrackingState.Modified, origTrackingState);
Assert.Equal(TrackingState.Unchanged, origOrder.TrackingState);
}
示例9: MergeChanges_Should_Set_Properties_For_Modified_Order_With_Updated_Customer
public void MergeChanges_Should_Set_Properties_For_Modified_Order_With_Updated_Customer()
{
// Arrange
var database = new MockNorthwind();
var origOrder = database.Orders[0];
var changeTracker = new ChangeTrackingCollection<Order>(origOrder);
origOrder.CustomerId = "ALFKI";
var updatedOrder = UpdateOrders(database, origOrder)[0];
// Act
changeTracker.MergeChanges(updatedOrder);
// Assert
Assert.AreEqual(updatedOrder.CustomerId, origOrder.CustomerId);
Assert.AreEqual(updatedOrder.Customer.CustomerId, origOrder.Customer.CustomerId);
Assert.AreEqual(updatedOrder.OrderDate, origOrder.OrderDate);
}
示例10: MergeChanges_Should_Set_ChangeTracker_For_Modified_Order_With_Updated_Customer
public void MergeChanges_Should_Set_ChangeTracker_For_Modified_Order_With_Updated_Customer()
{
// Arrange
var database = new MockNorthwind();
var origOrder = database.Orders[0];
var changeTracker = new ChangeTrackingCollection<Order>(origOrder);
origOrder.CustomerId = "ALFKI";
var updatedOrder = UpdateOrders(database, origOrder)[0];
// Act
changeTracker.MergeChanges(updatedOrder);
TrackingState origTrackingState = origOrder.Customer.TrackingState;
origOrder.Customer.CustomerName = "xxx";
// Assert
Assert.AreEqual(TrackingState.Unchanged, origTrackingState);
Assert.AreEqual(TrackingState.Modified, origOrder.Customer.TrackingState);
Assert.Contains("CustomerName", (ICollection)origOrder.Customer.ModifiedProperties);
}
示例11: GetChanges_Should_Return_Added_Modified_Deleted_Items
public void GetChanges_Should_Return_Added_Modified_Deleted_Items()
{
// Arrange
var database = new MockNorthwind();
var addedProduct = database.Products[0];
var updatedProduct = database.Products[1];
var deletedProduct = database.Products[2];
var changeTracker = new ChangeTrackingCollection<Product>(updatedProduct, deletedProduct);
changeTracker.Add(addedProduct);
updatedProduct.UnitPrice++;
changeTracker.Remove(deletedProduct);
// Act
var changes = changeTracker.GetChanges();
// Assert
Assert.AreEqual(TrackingState.Added, changes.ElementAt(1).TrackingState);
Assert.AreEqual(TrackingState.Modified, changes.ElementAt(0).TrackingState);
Assert.AreEqual(TrackingState.Deleted, changes.ElementAt(2).TrackingState);
}
示例12: Removed_Items_Should_NOT_Disable_Change_Tracking_On_Related_Entities_OneToMany_ToOne
public void Removed_Items_Should_NOT_Disable_Change_Tracking_On_Related_Entities_OneToMany_ToOne()
{
// Arrange
var database = new MockNorthwind();
var order = database.Orders[0];
var product = order.OrderDetails[0].Product;
var changeTracker = new ChangeTrackingCollection<Order>(order);
changeTracker.Remove(order);
// Act
product.ProductName = "XXX";
// Assert
Assert.AreEqual(TrackingState.Modified, product.TrackingState);
}
示例13: Removed_Items_Should_NOT_Disable_Change_Tracking_On_Related_Entities_OneToOne
public void Removed_Items_Should_NOT_Disable_Change_Tracking_On_Related_Entities_OneToOne()
{
// Arrange
var database = new MockNorthwind();
var customer = database.Orders[0].Customer;
var setting = customer.CustomerSetting = new CustomerSetting
{
CustomerId = customer.CustomerId,
Customer = customer,
Setting = "Setting1"
};
var changeTracker = new ChangeTrackingCollection<Customer>(customer);
changeTracker.Remove(customer);
// Act
setting.Setting = "XXX";
// Assert
Assert.AreEqual(TrackingState.Modified, setting.TrackingState);
}
示例14: Removed_Items_Should_Disable_Change_Tracking_On_Entity
public void Removed_Items_Should_Disable_Change_Tracking_On_Entity()
{
// Arrange
var database = new MockNorthwind();
var order = database.Orders[0];
var changeTracker = new ChangeTrackingCollection<Order>(order);
changeTracker.Remove(order);
order.TrackingState = TrackingState.Unchanged;
// Act
order.OrderDate = order.OrderDate.AddDays(1);
// Assert
Assert.AreEqual(TrackingState.Unchanged, order.TrackingState);
}
示例15: Added_Employee_After_Tracking_Enabled_Should_Not_Mark_Manually_Added_Territories_As_Unchanged
public void Added_Employee_After_Tracking_Enabled_Should_Not_Mark_Manually_Added_Territories_As_Unchanged()
{
// Arrange
var database = new MockNorthwind();
var employee = database.Employees[0];
employee.Territories.ToList().ForEach(t => t.TrackingState = TrackingState.Added);
var changeTracker = new ChangeTrackingCollection<Employee>(true);
// Act
changeTracker.Add(employee);
// Assert
Assert.AreEqual(TrackingState.Added, employee.TrackingState);
Assert.IsTrue(employee.Territories.All(t => t.TrackingState == TrackingState.Added));
}