コード例 #1
0
        public void TestDelete()
        {
            // Arrange
            var repo           = new ClimbingRoutesRepository <Ascent>(TestHelpers.GetNewContext());
            var initalExpected = 4;
            var finalExpected  = 3;

            // Act
            var initial = repo.All().Count();

            repo.Delete(1);
            var final = repo.All().Count();

            // Assert
            Assert.Equal(initalExpected, initial);
            Assert.Equal(finalExpected, finalExpected);
        }
コード例 #2
0
        public void TestUpdate()
        {
            // Arrange
            var    repo     = new ClimbingRoutesRepository <Climber>(TestHelpers.GetNewContext());
            string expected = "Zaphod";

            // Act
            var user    = repo.All().FirstOrDefault();
            var initial = user.FirstName;

            user.FirstName = expected;
            repo.Update(user);
            var actual = repo.All().FirstOrDefault().FirstName;

            // Assert
            Assert.NotEqual(expected, initial); // Make sure the names are not equal at the start
            Assert.Equal(expected, actual);
        }
コード例 #3
0
        public void TestAllMethod()
        {
            // Arrange
            var repo     = new ClimbingRoutesRepository <Climber>(TestHelpers.GetNewContext());
            var expected = 3;

            // Act
            var usersCount = repo.All().Count();

            // Assert
            Assert.Equal(expected, usersCount);
        }
コード例 #4
0
        public void TestInsert()
        {
            // Arrange
            var repo           = new ClimbingRoutesRepository <Ascent>(TestHelpers.GetNewContext());
            var initalExpected = 4;
            var finalExpected  = 5;
            var ascent         = new Ascent()
            {
                ClimberId = 2,
                RouteId   = 1,
                StyleId   = 2,
                Date      = new System.DateTime(year: 2019, month: 10, day: 18)
            };

            // Act
            var initial = repo.All().Count();

            repo.Insert(ascent);
            var final = repo.All().Count();

            // Assert
            Assert.Equal(initalExpected, initial);
            Assert.Equal(finalExpected, finalExpected);
        }