Esempio n. 1
0
        public async Task should_be_able_to_fetch_new_user_v2()
        {
            // Setup application
            var applicationFactory = new SampleApplicationFactory();
            await applicationFactory.Install();

            var apiClient = applicationFactory.CreateClient();


            // Create new users
            var createResponse = await apiClient.PostAsJsonAsync("/user/", new CreateUserDTO
            {
                FirstName = "John",
                LastName  = "Doe",
                Email     = "*****@*****.**"
            });

            var createResult = await createResponse.Content.ReadAsAsync <EntityCreatedResult>();

            // Fetch newly created user
            var getUserResponsePayload = await apiClient.GetStringAsync("/user/" + createResult.Id);

            // Verify the expectations
            Approvals.VerifyJson(getUserResponsePayload.WithIgnores("$.id"));
        }
Esempio n. 2
0
        public async Task should_be_able_to_fetch_new_user_v1()
        {
            // Setup application
            var applicationFactory = new SampleApplicationFactory();
            await applicationFactory.Install();

            var apiClient = applicationFactory.CreateClient();


            // Create new users
            var createResponse = await apiClient.PostAsJsonAsync("/user/", new CreateUserDTO
            {
                FirstName = "John",
                LastName  = "Doe",
                Email     = "*****@*****.**"
            });

            var createResult = await createResponse.Content.ReadAsAsync <EntityCreatedResult>();

            // Fetch newly created user
            var getUserResponse = await apiClient.GetAsync("/user/" + createResult.Id);

            var foundUser = await getUserResponse.Content.ReadAsAsync <UserDTO>();

            // Verify the expectations
            Assert.Multiple(() =>
            {
                Assert.AreEqual(createResult.Id, foundUser.Id, "User Id different than expected");
                Assert.AreEqual("John", foundUser.FirstName, "User FirstName different than expected");
                Assert.AreEqual("Doe", foundUser.LastName, "User LastName different than expected");
            });
        }