public void ReturnIqueryableCollectionFromCreatureDataProviderAllMethod()
        {
            //Arrange
            var mockedDataProvider = new Mock <IEfAquaWorldDataProvider <Creature> >();

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

            var actualResult = actualCreatureService.GetAllCreatures();

            //Assert
            Assert.That(actualResult, Is.Not.Null.And.InstanceOf <IQueryable <Creature> >());
        }
        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>());
        }
        public void CallCreatureDataProviderGetAllMethodWithSameId(int correctId)
        {
            //Arrange
            var mockedDataProvider = new Mock <IEfAquaWorldDataProvider <Creature> >();

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

            actualCreatureService.GetCreatureById(correctId);

            //Assert
            mockedDataProvider.Verify(
                service => service.GetById(correctId),
                Times.Once);
        }
        public void CallCreatureDataProviderAllMethod()
        {
            //Arrange
            var mockedDataProvider = new Mock <IEfAquaWorldDataProvider <Creature> >();

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

            actualCreatureService.GetAllCreatures();

            //Assert
            mockedDataProvider.Verify(
                service => service.All(),
                Times.Once);
        }
Exemple #5
0
        public void CallCreatureDataProviderAddMethodWithSameRecievedCreature()
        {
            //Arrange
            var mockedDataProvider = new Mock <IEfAquaWorldDataProvider <Creature> >();
            var mockedCreature     = new Mock <Creature>();

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

            actualCreatureService.Create(mockedCreature.Object);

            //Assert
            mockedDataProvider.Verify(
                service => service.Add(mockedCreature.Object),
                Times.Once);
        }
        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);
        }