• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Mocks.MockNorthwind类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TrackableEntities.Client.Tests.Entities.Mocks.MockNorthwind的典型用法代码示例。如果您正苦于以下问题:C# MockNorthwind类的具体用法?C# MockNorthwind怎么用?C# MockNorthwind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MockNorthwind类属于TrackableEntities.Client.Tests.Entities.Mocks命名空间,在下文中一共展示了MockNorthwind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
开发者ID:luboshl,项目名称:trackable-entities,代码行数:30,代码来源:ChangeTrackingCollectionWithChildrenTests.cs


示例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);
        }
开发者ID:luboshl,项目名称:trackable-entities,代码行数:30,代码来源:ChangeTrackingCollectionWithChildrenTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:12,代码来源:ChangeTrackingCollectionTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:13,代码来源:ChangeTrackingCollectionTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:13,代码来源:ChangeTrackingCollectionTests.cs


示例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);
        }
开发者ID:luboshl,项目名称:trackable-entities,代码行数:15,代码来源:ChangeTrackingCollectionWithChildrenTests.cs


示例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);
        }
开发者ID:luboshl,项目名称:trackable-entities,代码行数:17,代码来源:ChangeTrackingExtensionsTests.cs


示例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);
        }
开发者ID:luboshl,项目名称:trackable-entities,代码行数:17,代码来源:ChangeTrackingExtensionsTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:17,代码来源:ChangeTrackingExtensionsTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:19,代码来源:ChangeTrackingExtensionsTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:22,代码来源:ChangeTrackingCollectionTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:16,代码来源:ChangeTrackingCollectionTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:21,代码来源:ChangeTrackingCollectionTests.cs


示例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);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:16,代码来源:ChangeTrackingCollectionTests.cs


示例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));
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:15,代码来源:ChangeTrackingCollectionTests.cs


示例16: Removed_Existing_Modified_Items_Should_Be_Marked_As_Deleted

        public void Removed_Existing_Modified_Items_Should_Be_Marked_As_Deleted()
        {
            // Arrange
            var database = new MockNorthwind();
            var changeTracker = new ChangeTrackingCollection<Product>(database.Products[0]);
            var product = changeTracker[0];
            product.UnitPrice++;

            // Act
            changeTracker.Remove(product);

            // Assert
            Assert.AreEqual(TrackingState.Deleted, product.TrackingState);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:14,代码来源:ChangeTrackingCollectionTests.cs


示例17: Removed_Existing_Modified_Items_Should_Not_Have_ModifiedProperties

        public void Removed_Existing_Modified_Items_Should_Not_Have_ModifiedProperties()
        {
            // Arrange
            var database = new MockNorthwind();
            var changeTracker = new ChangeTrackingCollection<Product>(database.Products[0]);
            var product = changeTracker[0];
            product.UnitPrice++;

            // Act
            changeTracker.Remove(product);

            // Assert
            Assert.IsTrue(product.ModifiedProperties == null
                || product.ModifiedProperties.Count == 0);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:15,代码来源:ChangeTrackingCollectionTests.cs


示例18: Modified_Existing_Items_Should_Add_ModifiedProperty

        public void Modified_Existing_Items_Should_Add_ModifiedProperty()
        {
            // Arrange
            var database = new MockNorthwind();
            var changeTracker = new ChangeTrackingCollection<Product>(database.Products[0]);
            var product = changeTracker[0];

            // Act
            product.UnitPrice++;

            // Assert
            Assert.Contains("UnitPrice", (ICollection)product.ModifiedProperties);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:13,代码来源:ChangeTrackingCollectionTests.cs


示例19: Removed_Items_Should_Disable_Change_Tracking_On_Related_Entities_OneToMany

        public void Removed_Items_Should_Disable_Change_Tracking_On_Related_Entities_OneToMany()
        {
            // Arrange
            var database = new MockNorthwind();
            var order = database.Orders[0];
            var detail = order.OrderDetails[0];

            var changeTracker = new ChangeTrackingCollection<Order>(order);
            changeTracker.Remove(order);
            detail.TrackingState = TrackingState.Unchanged;

            // Act
            detail.Quantity++;

            // Assert
            Assert.AreEqual(TrackingState.Unchanged, detail.TrackingState);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:17,代码来源:ChangeTrackingCollectionTests.cs


示例20: Modified_Existing_Excluded_Items_Should_Not_Be_Marked_As_Modified

        public void Modified_Existing_Excluded_Items_Should_Not_Be_Marked_As_Modified()
        {
            // Arrange
            var database = new MockNorthwind();
            var changeTracker = new ChangeTrackingCollection<Product>(database.Products[0]);
            changeTracker.ExcludedProperties.Add("UnitPrice");
            var product = changeTracker[0];

            // Act
            product.UnitPrice++;

            // Assert
            Assert.AreEqual(TrackingState.Unchanged, product.TrackingState);
        }
开发者ID:stevedelong,项目名称:trackable-entities,代码行数:14,代码来源:ChangeTrackingCollectionTests.cs



注:本文中的TrackableEntities.Client.Tests.Entities.Mocks.MockNorthwind类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Mocks.MockNorthwind类代码示例发布时间:2022-05-26
下一篇:
C# Tpm2Lib.TpmHandle类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap