예제 #1
0
        public void ThrowWhenArgumentCreatureHasNullValue()
        {
            //Arrange
            var      mockedDataProvider = new Mock <IEfAquaWorldDataProvider <Creature> >();
            Creature nullCreature       = null;

            //Act
            var actualCreatureService =
                new AquaWorld.Data.Services.CreatureService(mockedDataProvider.Object);

            //Assert
            Assert.That(
                () => actualCreatureService.UpdateCreature(nullCreature),
                Throws.InstanceOf <ArgumentNullException>());
        }
예제 #2
0
        public void CallCreatureDataProviderSaveChangesMethod()
        {
            //Arrange
            var mockedDataProvider = new Mock <IEfAquaWorldDataProvider <Creature> >();
            var mockedCreature     = new Creature()
            {
                Id = 1
            };

            mockedDataProvider.Setup(x => x.GetById(1)).Returns(mockedCreature);
            //Act
            var actualCreatureService =
                new AquaWorld.Data.Services.CreatureService(mockedDataProvider.Object);

            actualCreatureService.UpdateCreature(mockedCreature);

            //Assert
            mockedDataProvider.Verify(
                service => service.SaveChanges(),
                Times.Once);
        }