public void Setup()
        {
            //Inicializa o banco, apagando e recriando-o
            Database.SetInitializer(new DropCreateDatabaseAlways <CustomerContext>());
            //Seta um registro padrão pra ser usado nos testes
            _contextForTest = new CustomerContext();
            var accommodation = ObjectMother.GetAccommodation();

            _contextForTest.Accommodations.Add(accommodation);
            _contextForTest.SaveChanges();
        }
        public void CreateAccommodationRepositoryTest()
        {
            //Arrange
            Accommodation            p          = ObjectMother.GetAccommodation();
            IAccommodationRepository repository = new AccommodationRepository();

            //Action
            Accommodation newAccommodation = repository.Save(p);

            //Assert
            Assert.IsTrue(newAccommodation.Id > 0);
        }
示例#3
0
        public void RetrieveAccommodationServiceTest()
        {
            //Arrange
            Accommodation accommodation = ObjectMother.GetAccommodation();
            //Fake do repositório
            var repositoryFake = new Mock <IAccommodationRepository>();

            repositoryFake.Setup(r => r.Get(1)).Returns(accommodation);

            IAccommodationService service = new AccommodationService(repositoryFake.Object);

            //Action
            var accommodationFake = service.Retrieve(1);

            //Assert
            repositoryFake.Verify(r => r.Get(1));
            Assert.IsNotNull(accommodationFake);
        }
示例#4
0
        public void UpdateAccommodationServiceValidationAndPersistenceTest()
        {
            //Arrange
            Accommodation accommodation = ObjectMother.GetAccommodation();
            //Fake do repositório
            var repositoryFake = new Mock <IAccommodationRepository>();

            repositoryFake.Setup(r => r.Update(accommodation)).Returns(accommodation);
            //Fake do dominio
            var accommodationFake = new Mock <Accommodation>();

            accommodationFake.As <IObjectValidation>().Setup(b => b.Validate());

            IAccommodationService service = new AccommodationService(repositoryFake.Object);

            //Action
            service.Update(accommodationFake.Object);

            //Assert
            accommodationFake.As <IObjectValidation>().Verify(b => b.Validate());
            repositoryFake.Verify(r => r.Update(accommodationFake.Object));
        }
示例#5
0
        public void CreateAValidAccommodationTest()
        {
            Accommodation accommodation = ObjectMother.GetAccommodation();

            Validator.Validate(accommodation);
        }
示例#6
0
        public void CreateAAccommodationTest()
        {
            Accommodation accommodation = ObjectMother.GetAccommodation();

            Assert.IsNotNull(accommodation);
        }