Example #1
0
        public void Test_NuevoAnuncio_Calls_Insert_When_User_Found()
        {
            // Arrange
            var userStore = new InMemoryUserStore();

            userStore._users.Add("", new ApplicationUser()
            {
                Nombre   = "test",
                Apellido = "test",
                Email    = "*****@*****.**"
            });
            var userManager = new ApplicationUserManager(userStore);


            var mockRepository = new Mock <IRepositorioGenerico <Anuncio> >();

            mockRepository.Setup(mock => mock.Insert(It.IsAny <Anuncio>()));
            mockRepository.Setup(mock => mock.Save());

            var service = new AnunciosService(mockRepository.Object, userManager);

            var anuncio = TestHelpers.GetListAnuncios()[0];

            anuncio.Anunciante = null;
            // Act
            service.AddAnuncio(anuncio, "*****@*****.**");

            // Assert
            mockRepository.Verify(m => m.Insert(It.IsAny <Anuncio>()));
            mockRepository.Verify(m => m.Save());
        }
Example #2
0
        public void Test_NuevoAnuncio_Throws_When_User_Not_Found()
        {
            // Arrange
            var userStore   = new InMemoryUserStore();
            var userManager = new ApplicationUserManager(userStore);


            var mockRepository = new Mock <IRepositorioGenerico <Anuncio> >();

            mockRepository.Setup(mock => mock.Insert(It.IsAny <Anuncio>()));
            mockRepository.Setup(mock => mock.Save());

            var service = new AnunciosService(mockRepository.Object, userManager);

            var anuncio = TestHelpers.GetListAnuncios()[0];

            anuncio.Anunciante = null;
            // Act
            service.AddAnuncio(anuncio, "*****@*****.**");

            // Assert
        }