Beispiel #1
0
        public void RaceManager_RemoveRaceAbility_ValidCall()
        {
            //Arrange
            List <RaceAbility> raceAbilities = CreateTestData.GetListOfRaceAbility();
            var mockSet = new Mock <DbSet <RaceAbility> >()
                          .SetupData(raceAbilities, o =>
            {
                return(raceAbilities.Single(x => x.RaceAbility_id.CompareTo(o.First()) == 0));
            });
            var toBeDeleted = CreateTestData.GetSampleRaceAbility();

            using (var mockContext = AutoMock.GetLoose())
            {
                mockContext.Mock <RaceContext>()
                .Setup(x => x.RaceAbilities).Returns(mockSet.Object);

                //Act
                IUnitOfWork            worker = mockContext.Create <UnitOfWork>();
                IRaceManagerUserAccess toTest = UserAccessFactory.GetRaceManagerUserAccess(worker);
                toTest.RemoveRaceAbility(toBeDeleted);

                //Assert
                raceAbilities.Should().NotContain(toBeDeleted);
            }
        }
Beispiel #2
0
        public void RaceRepository_GetAbilitiesOfRace_ValidCall()
        {
            //Arrange
            List <RaceAbility> raceAbilities = CreateTestData.GetListOfRaceAbility();
            var mockSet = new Mock <DbSet <RaceAbility> >()
                          .SetupData(raceAbilities, o =>
            {
                return(raceAbilities.Single(x => x.RaceAbility_id.CompareTo(o.First()) == 0));
            });
            var expected = CreateTestData.GetSampleRaceAbility();

            using (var mockContext = AutoMock.GetLoose())
            {
                mockContext.Mock <RaceContext>()
                .Setup(x => x.RaceAbilities).Returns(mockSet.Object);

                //Act
                var toTest = mockContext.Create <RaceRepository>();
                var actual = toTest.GetAbilitiesOfRace(expected.Race_id).ToList();

                //Assert
                actual.Should().NotBeNull();
                expected.Should().NotBeNull();
                actual.Should().BeOfType <List <RaceAbility> >();
                expected.Should().BeOfType <RaceAbility>();
                actual.Should().ContainEquivalentOf(expected);
            }
        }