Esempio n. 1
0
        public async Task PossivelRetornoUpdated()
        {
            var serviceMock = new Mock <IUserService>();
            var nome        = Faker.Name.FullName();
            var email       = Faker.Internet.Email();

            serviceMock.Setup(m => m.Put(It.IsAny <UseDtoUpdate>()))
            .ReturnsAsync(
                new UseDtoUpdateResult
            {
                Id       = Guid.NewGuid(),
                Name     = nome,
                Email    = email,
                UpdateAt = DateTime.UtcNow
            }
                );
            _controller = new UsersController(serviceMock.Object);

            var useDtoUpdate = new UseDtoUpdate
            {
                Id    = Guid.NewGuid(),
                Name  = nome,
                Email = email
            };

            var result = await _controller.Put(useDtoUpdate);

            Assert.True(result is OkObjectResult);

            UseDtoUpdateResult useDtoUpdateResult = ((OkObjectResult)result).Value as UseDtoUpdateResult;

            Assert.NotNull(useDtoUpdateResult);
            Assert.Equal(useDtoUpdate.Name, useDtoUpdateResult.Name);
            Assert.Equal(useDtoUpdate.Email, useDtoUpdateResult.Email);
        }
Esempio n. 2
0
        public UsuarioTeste()
        {
            IdUsuario            = Guid.NewGuid();
            NomeUsuario          = Faker.Name.FullName();
            EmailUsuario         = Faker.Internet.Email();
            NomeUsuarioAlterado  = Faker.Name.FullName();
            EmailUsuarioAlterado = Faker.Internet.Email();

            for (int i = 0; i < 20; i++)
            {
                var dto = new UseDto()
                {
                    Id    = Guid.NewGuid(),
                    Name  = Faker.Name.FullName(),
                    Email = Faker.Internet.Email()
                };
                listaUserDto.Add(dto);
            }
            useDto = new UseDto
            {
                Id    = IdUsuario,
                Name  = NomeUsuario,
                Email = EmailUsuario
            };
            useDtoCreate = new UseDtoCreate
            {
                Name  = NomeUsuario,
                Email = EmailUsuario
            };
            useDtoCreateResult = new UseDtoCreateResult
            {
                Id       = IdUsuario,
                Name     = NomeUsuario,
                Email    = EmailUsuario,
                CreateAt = DateTime.UtcNow
            };
            useDtoUpdate = new UseDtoUpdate
            {
                Id    = IdUsuario,
                Name  = NomeUsuarioAlterado,
                Email = EmailUsuarioAlterado
            };
            useDtoUpdateResult = new UseDtoUpdateResult
            {
                Id       = IdUsuario,
                Name     = NomeUsuarioAlterado,
                Email    = EmailUsuarioAlterado,
                UpdateAt = DateTime.UtcNow
            };
        }