private void AddIdRange(Range range) { (int offset, int length) = range.GetOffsetAndLength(range.End.Value); for (var id = range.Start.Value; id <= offset + length; id++) { var testViewModel = CreateItem(id); ClassUnderTest.Add(testViewModel); } }
public void ClearAndAdd_ShouldBeAddedFirst() { //Arrange AddIdRange(new Range(2, 5)); ClassUnderTest.Clear(); //Act ClassUnderTest.Add(CreateItem(1)); //Assert ClassUnderTest[0].Id.Should().Be(1); ClassUnderTest.Count.Should().Be(1); }
public void FilteredModelsWasNotAdded() { //Arrange var model3 = TestModelProvider.Model3; model3.Name = "Filter"; //Act ClassUnderTest.Add(model3); //Assert ClassUnderTest.Items.Count.Should().Be(1); ClassUnderTest.Items.FirstOrDefault(c => c.Id == TestModelProvider.Model1.Id).Should().NotBeNull(); ClassUnderTest.Items.FirstOrDefault(c => c.Id == model3.Id).Should().BeNull(); }
protected override void Given() { for (int i = 1; i <= 20; i++) { var foosballPlayer = new FoosballPlayer { Id = Guid.NewGuid(), Name = "Player " + i, Born = DateTime.Now.AddYears(-30), Rank = i }; ClassUnderTest.Add(foosballPlayer); } }
public void AddId1_ShouldBeAddedFirst() { //Arrange var range = new Range(2, 5); AddIdRange(range); int expectedItemsCount = ClassUnderTest.Count + 1; //Act ClassUnderTest.Add(CreateItem(1)); //Assert ClassUnderTest[0].Id.Should().Be(1); ClassUnderTest.Count.Should().Be(expectedItemsCount); }
public void Sort_NameChanged() { //Arrange ClassUnderTest.Add(TestModelProvider.Model2); ClassUnderTest.Add(TestModelProvider.Model3); var model1ViewModel = ClassUnderTest.Items.First(c => c.Id == 1); model1ViewModel.Should().BeSameAs(ClassUnderTest.Items[2]); //Act model1ViewModel.Name = "z"; //Assert model1ViewModel.Should().BeSameAs(ClassUnderTest.Items[0]); }
public void Sort_ReverseOrder() { //Arrange ClassUnderTest.Add(TestModelProvider.Model2); var model3 = TestModelProvider.Model3; model3.Name = "a"; ClassUnderTest.Add(model3); var originalOrder = ClassUnderTest.Items.ToList(); //Act ClassUnderTest.SetAscendingNameSortDescription(); //Assert originalOrder.Reverse(); ClassUnderTest.Items.ToList().SequenceEqual(originalOrder).Should().BeTrue(); }
public void Sort_ItemsAreOrderedByNameDescThenByIdAsc() { //Arrange var model2 = TestModelProvider.Model2; model2.Name = "z"; var model3 = TestModelProvider.Model3; model3.Name = "z"; //Act ClassUnderTest.Add(model2); ClassUnderTest.Add(model3); //Assert var expectedOrder = new[] { TestModelProvider.Model2, TestModelProvider.Model3, TestModelProvider.Model1 } .Select(c => c.Id); ClassUnderTest.Items.Select(c => c.Id).SequenceEqual(expectedOrder).Should().BeTrue(); }
protected override void Given() { var lousyFoosballPlayer = new FoosballPlayer { Id = Guid.NewGuid(), Name = StefanAniff, Born = new DateTime(1985, 9, 12), Rank = Rank }; ClassUnderTest.Add(lousyFoosballPlayer); var bestFoosballPlayer = new FoosballPlayer { Id = Guid.NewGuid(), Name = "Frederic Collignon", Born = new DateTime(1980, 2, 15), Rank = 1 }; ClassUnderTest.Add(bestFoosballPlayer); }
public void AddNull() { //Act ClassUnderTest.Add(null); }