コード例 #1
0
            public void ShouldReturnFalseIfItemToUpdateDoesNotExist()
            {
                // Arrange
                TestObject objectToAdd        = TestObjectFaker.Create().Generate();
                TestObject objectToUpdateWith = TestObjectFaker.Create().Generate();

                var list = new List <TestObject> {
                    objectToAdd
                };

                // Act
                bool updated = list.Update(objectToUpdateWith, (s, i) => s.Name == objectToUpdateWith.Name);

                // Assert
                updated.ShouldBeFalse();
            }
コード例 #2
0
            public void ShouldAddRangeOfItems()
            {
                // Arrange
                List <TestObject> objectsToAdd = TestObjectFaker.Create().Generate(10);

                var collection = new ObservableCollection <TestObject>();

                // Act
                collection.AddRange(objectsToAdd);

                // Assert
                foreach (TestObject item in objectsToAdd)
                {
                    collection.ShouldContain(item);
                }
            }
コード例 #3
0
            public void ShouldRemoveRangeOfItems()
            {
                // Arrange
                List <TestObject> items = TestObjectFaker.Create().Generate(10);
                var itemsToRemove       = items.Take(5).ToList();

                var collection = new ObservableCollection <TestObject>(items);

                // Act
                collection.RemoveRange(itemsToRemove);

                // Assert
                foreach (TestObject item in itemsToRemove)
                {
                    collection.ShouldNotContain(item);
                }
            }