Exemplo n.º 1
0
        public async Task CreateUserWithBadData()
        {
            swaggerClient client = new swaggerClient(baseUrl, httpClient);

            CreateUserCommand command = new CreateUserCommand()
            {
                FirstName    = "Some",
                MiddleName   = "Tandem",
                LastName     = "User",
                PhoneNumber  = "not a phone number",
                EmailAddress = $"{Guid.NewGuid()}@foo.bar"
            };

            ApiException phoneNumberException = await Assert.ThrowsExceptionAsync <ApiException>(
                () => client.UsersAsync(command));

            command.PhoneNumber  = "222-333-4444";
            command.EmailAddress = "not an email";

            ApiException emailException = await Assert.ThrowsExceptionAsync <ApiException>(
                () => client.UsersAsync(command));

            Assert.AreEqual(400, phoneNumberException.StatusCode);
            Assert.AreEqual(400, emailException.StatusCode);
        }
Exemplo n.º 2
0
        public async Task CreateThenFindUser()
        {
            swaggerClient client = new swaggerClient(baseUrl, httpClient);

            CreateUserCommand command = new CreateUserCommand()
            {
                FirstName    = "Some",
                MiddleName   = "Tandem",
                LastName     = "User",
                PhoneNumber  = "111-222-3333",
                EmailAddress = $"{Guid.NewGuid()}@foo.bar"
            };

            await client.UsersAsync(command);

            UserDetailView savedUser = await client.Users2Async(command.EmailAddress);

            string expectedName = $"{command.FirstName} {command.MiddleName} {command.LastName}";

            Assert.AreEqual(expectedName, savedUser.Name);
            Assert.AreEqual(command.EmailAddress, savedUser.EmailAddress);
            Assert.AreEqual(command.EmailAddress, savedUser.EmailAddress);
        }