Пример #1
0
        public async Task Post_ReturnCryptoCurrencyRates()
        {
            var initResponse = await _client.GetAsync("/");

            var antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(initResponse);

            var postRequest = new HttpRequestMessage(HttpMethod.Post, "/");

            postRequest.Headers.Add("Cookie", new CookieHeaderValue(AntiForgeryTokenExtractor.AntiForgeryCookieName, antiForgeryValues.cookieValue).ToString());

            var formModel = new Dictionary <string, string>
            {
                {
                    AntiForgeryTokenExtractor.AntiForgeryFieldName,
                    antiForgeryValues.fieldValue
                },
                { "SelectedCryptoCurrency", "BTC" }
            };

            postRequest.Content = new FormUrlEncodedContent(formModel);
            var response = await _client.SendAsync(postRequest);

            response.EnsureSuccessStatusCode();
            var content = await HtmlHelpers.GetDocumentAsync(response);

            var rateCards = content.QuerySelectorAll("div.card");

            Assert.True(rateCards.Any());
        }
        public async Task Create_When_POST_Executed_Returns_To_Index_View_With_Create_Person()
        {
            var initResponse = await _client.GetAsync("/Persons/Create");

            var(fieldValue, cookieValue) = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(initResponse);

            var postRequest = new HttpRequestMessage(HttpMethod.Post, "/Persons/Create");

            postRequest.Headers.Add("Cookie", new CookieHeaderValue(AntiForgeryTokenExtractor.AntiForgeryCookieName, cookieValue).ToString());

            var formModel = new Dictionary <string, string>
            {
                { AntiForgeryTokenExtractor.AntiForgeryFieldName, fieldValue },
                { "Name", "New Person" },
                { "GroupId", "1" }
            };

            postRequest.Content = new FormUrlEncodedContent(formModel);

            var response = await _client.SendAsync(postRequest);

            response.EnsureSuccessStatusCode();

            var responseString = await response.Content.ReadAsStringAsync();

            Assert.Contains("New Person", responseString);
            Assert.Contains("GroupB", responseString);
        }
Пример #3
0
        public async Task Post_DeleteConfirmed_Returns_Redirect_To_Root()
        {
            // Arrange
            var initResponse = await _client.GetAsync("/Event/Delete/1");

            var(fieldValue, cookieValue) = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(initResponse);

            var postRequest = new HttpRequestMessage(HttpMethod.Post, "/Event/DeleteConfirmed/1");

            postRequest.Headers.Add("Cookie", new CookieHeaderValue(AntiForgeryTokenExtractor.AntiForgeryCookieName, cookieValue).ToString());
            var formModel = new Dictionary <string, string>
            {
                [AntiForgeryTokenExtractor.AntiForgeryFieldName] = fieldValue,
                ["Id"] = "1"
            };

            //Act
            postRequest.Content = new FormUrlEncodedContent(formModel);
            var response = await _client.SendAsync(postRequest);

            // Assert
            Assert.Equal(HttpStatusCode.OK, initResponse.StatusCode);
            Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
            Assert.Equal("/Event", response.Headers.Location.OriginalString);
        }
Пример #4
0
        public async Task Should_Update_Movie_On_Edit()
        {
            // Arrange
            var terminatorMovie = new Movie()
            {
                Id = 1, Title = "Terminator 2", Genre = "Action"
            };
            var client = factory
                         .WithMoviesInDatabase(new List <Movie>()
            {
                terminatorMovie
            })
                         .CreateClient();

            terminatorMovie.Title = "Terminator 2: Judgment Day";
            var expected = System.Net.HttpStatusCode.OK;
            var response = await client.GetAsync($"movies/edit/{terminatorMovie.Id}");

            response.EnsureSuccessStatusCode();
            var(fieldValue, cookieValue) = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

            var postRequest = new HttpRequestMessage(HttpMethod.Post, $"movies/edit/{terminatorMovie.Id}");

            postRequest.Headers.Add("Cookie",
                                    new CookieHeaderValue(AntiForgeryTokenExtractor.AntiForgeryCookieName,
                                                          cookieValue).ToString());

            var formModel = new Dictionary <string, string>
            {
                { AntiForgeryTokenExtractor.AntiForgeryFieldName, fieldValue },
                { nameof(terminatorMovie.Title), terminatorMovie.Title },
                { nameof(terminatorMovie.Genre), terminatorMovie.Genre },
                { nameof(terminatorMovie.Price), terminatorMovie.Price.ToString() },
                { nameof(terminatorMovie.ReleaseDate), terminatorMovie.ReleaseDate.ToString() },
            };

            postRequest.Content = new FormUrlEncodedContent(formModel);


            // Act
            response = await client.SendAsync(postRequest);

            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();

            // Assert
            Assert.NotNull(response);
            Assert.Equal(response.StatusCode, expected);
            Assert.Contains(terminatorMovie.Title, content);
        }
Пример #5
0
        public async Task Post_Edit_Invalid_Returns_Edit()
        {
            var initResponse = await _client.GetAsync("/Event/Edit/1");

            var(fieldValue, cookieValue) = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(initResponse);

            var postRequest = new HttpRequestMessage(HttpMethod.Post, "/Event/Edit/1");

            postRequest.Headers.Add("Cookie", new CookieHeaderValue(AntiForgeryTokenExtractor.AntiForgeryCookieName, cookieValue).ToString());

            var formModel = new Dictionary <string, string>
            {
                [AntiForgeryTokenExtractor.AntiForgeryFieldName] = fieldValue,
                ["Id"]                          = "1",
                ["Title"]                       = "", // empty string title should cause invalid
                ["Description"]                 = "This is a test event description",
                ["StartDate"]                   = "07/01/3000 1:07 PM",
                ["EndDate"]                     = "07/02/3000 11:07 PM",
                ["EventTypeId"]                 = "1",
                ["EventSeriesId"]               = null,
                ["FundCenter"]                  = null,
                ["RegistrationOpenDate"]        = "06/21/3000 1:07 PM",
                ["RegistrationClosedDate"]      = "06/30/3000 1:07 PM",
                ["MinRegistrationCount"]        = "1",
                ["MaxRegistrationCount"]        = "10",
                ["MaxStandbyRegistrationCount"] = null,
                ["AddressLine1"]                = "123 Anywhere St.",
                ["AddressLine2"]                = null,
                ["City"]                        = "Yourtown",
                ["State"]                       = "MD",
                ["Zip"]                         = "12345",
                ["AllowStandby"]                = "false"
            };

            postRequest.Content = new FormUrlEncodedContent(formModel);

            var response = await _client.SendAsync(postRequest);


            var responseString = await response.Content.ReadAsStringAsync();

            // Assert
            Assert.Equal(HttpStatusCode.OK, initResponse.StatusCode);
            Assert.Contains("Edit Event: Error", responseString);
        }
Пример #6
0
        public async Task Post_Create_Returns_Redirect_To_Root()
        {
            // Arrange
            var initResponse = await _client.GetAsync("/Event/Create");

            var(fieldValue, cookieValue) = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(initResponse);

            var postRequest = new HttpRequestMessage(HttpMethod.Post, "/Event/Create");

            postRequest.Headers.Add("Cookie", new CookieHeaderValue(AntiForgeryTokenExtractor.AntiForgeryCookieName, cookieValue).ToString());

            var formModel = new Dictionary <string, string>
            {
                [AntiForgeryTokenExtractor.AntiForgeryFieldName] = fieldValue,
                ["Title"]                       = "Test Created Event",
                ["Description"]                 = "This is a test event description",
                ["StartDate"]                   = "07/01/3000 1:07 PM",
                ["EndDate"]                     = "07/02/3000 11:07 PM",
                ["EventTypeId"]                 = "1",
                ["EventSeriesId"]               = null,
                ["FundCenter"]                  = null,
                ["RegistrationOpenDate"]        = "06/21/3000 1:07 PM",
                ["RegistrationClosedDate"]      = "06/30/3000 1:07 PM",
                ["MinRegistrationCount"]        = "1",
                ["MaxRegistrationCount"]        = "10",
                ["MaxStandbyRegistrationCount"] = null,
                ["AddressLine1"]                = "123 Anywhere St.",
                ["AddressLine2"]                = null,
                ["City"]         = "Yourtown",
                ["State"]        = "MD",
                ["Zip"]          = "12345",
                ["AllowStandby"] = "false"
            };

            //Act
            postRequest.Content = new FormUrlEncodedContent(formModel);

            var response = await _client.SendAsync(postRequest);

            // Assert
            Assert.Equal(HttpStatusCode.OK, initResponse.StatusCode);
            Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
            Assert.Equal("/Event", response.Headers.Location.OriginalString);
        }
Пример #7
0
        public async Task Should_Create_Movie_On_Create_Page()
        {
            // Arrange
            var gremlinsMovie = new Movie()
            {
                Id = GREMLINS_MOVIE_ID, Title = "Gremlins", Genre = "Action"
            };

            var expected = System.Net.HttpStatusCode.OK;
            var response = await client.GetAsync("movies/create");

            response.EnsureSuccessStatusCode();
            var(fieldValue, cookieValue) = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

            var postRequest = new HttpRequestMessage(HttpMethod.Post, "movies/create");

            postRequest.Headers.Add("Cookie",
                                    new CookieHeaderValue(AntiForgeryTokenExtractor.AntiForgeryCookieName,
                                                          cookieValue).ToString());

            var formModel = new Dictionary <string, string>
            {
                { AntiForgeryTokenExtractor.AntiForgeryFieldName, fieldValue },
                { nameof(gremlinsMovie.Title), gremlinsMovie.Title },
                { nameof(gremlinsMovie.Genre), gremlinsMovie.Genre },
                { nameof(gremlinsMovie.Price), gremlinsMovie.Price.ToString() },
                { nameof(gremlinsMovie.ReleaseDate), gremlinsMovie.ReleaseDate.ToString() },
            };

            postRequest.Content = new FormUrlEncodedContent(formModel);


            // Act
            response = await client.SendAsync(postRequest);

            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();

            // Assert
            Assert.NotNull(response);
            Assert.Equal(response.StatusCode, expected);
            Assert.Contains(gremlinsMovie.Title, content);
        }
        public async Task Get_Filter_By_Family_And_SubFamily_Return_All_Ok()
        {
            using (TestServer sharethingsServer = new ShareThingsScenarioBase().CreateServer())
            {
                HttpClient productClient = shareThingsScenarioBase.CreateHttpClientLender(sharethingsServer);
                HttpClient homeClient    = shareThingsScenarioBase.CreateHttpClientLender(sharethingsServer);

                string type    = "TestType";
                string subtype = "TestSubtype";
                int    productId;

                #region Create product
                HttpResponseMessage response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.CreateProduct);

                var antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                HttpRequestMessage postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Product.Post.CreateProduct, antiForgeryValues)
                                                 .Set("Name", "TestName")
                                                 .Set("Description", "TestDescriptionCreated")
                                                 .Set("Type", type)
                                                 .Set("Subtype", subtype)
                                                 .Set("Start", DateTime.Now.AddDays(-6).ToString("yyyy-MM-dd HH:mm:ss"))
                                                 .Set("End", DateTime.Now.AddDays(26).ToString("yyyy-MM-dd HH:mm:ss"))
                                                 .Build();

                response = await productClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Product.Get.GetProducts, response.Headers.Location.OriginalString);

                // Get Id product
                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.GetProducts);

                string responseString = await response.Content.ReadAsStringAsync();

                string key   = "/Products/Edit/";
                int    index = responseString.IndexOf(key);
                productId = Convert.ToInt32(responseString.Substring(index + key.Length, 1));
                #endregion

                #region Home
                response = await homeClient.GetAsync(ShareThingsScenarioBase.Home.Get.GetHome);

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                key = string.Format("/Products/Details/{0}", productId);
                Assert.Contains(key, responseString);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Get, ShareThingsScenarioBase.Home.Get.GetHome, antiForgeryValues)
                              .Set("Family", type)
                              .Set("SubFamily", subtype)
                              .Build();

                response = await homeClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                #endregion
            }
        }
Пример #9
0
        public async Task Post_Create_Update_ChangeStatus_Delete_Product_Return_All_Ok()
        {
            using (TestServer sharethingsServer = new ShareThingsScenarioBase().CreateServer())
            {
                HttpClient productClient = shareThingsScenarioBase.CreateHttpClientLender(sharethingsServer);

                #region Create product
                HttpResponseMessage response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.CreateProduct);

                var antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                HttpRequestMessage postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Product.Post.CreateProduct, antiForgeryValues)
                                                 .Set("Name", "TestName")
                                                 .Set("Description", "TestDescriptionCreated")
                                                 .Set("Type", "TestType")
                                                 .Set("Subtype", "TestSubtype")
                                                 .Set("Start", DateTime.Now.AddDays(-6).ToString("yyyy-MM-dd HH:mm:ss"))
                                                 .Set("End", DateTime.Now.AddDays(26).ToString("yyyy-MM-dd HH:mm:ss"))
                                                 .Build();

                response = await productClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Product.Get.GetProducts, response.Headers.Location.OriginalString);

                // Get Id product
                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.GetProducts);

                string responseString = await response.Content.ReadAsStringAsync();

                string key       = "/Products/Edit/";
                int    index     = responseString.IndexOf(key);
                int    productId = Convert.ToInt32(responseString.Substring(index + key.Length, 1));
                #endregion

                #region Get detail productId
                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.GetDetails(productId));

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                Assert.Contains("TestDescriptionCreated", responseString);
                Assert.DoesNotContain("TestDescriptionUpdated", responseString);
                #endregion

                #region Edit product
                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Common.EditProduct(productId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Product.Common.EditProduct(productId), antiForgeryValues)
                              .Set("ProductId", productId.ToString())
                              .Set("Name", "TestName")
                              .Set("Description", "TestDescriptionUpdated")
                              .Set("Type", "TestType")
                              .Set("Subtype", "TestSubtype")
                              .Build();

                response = await productClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Product.Get.GetProducts, response.Headers.Location.OriginalString);

                // Get detail productId
                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.GetDetails(productId));

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                Assert.DoesNotContain("TestDescriptionCreated", responseString);
                Assert.Contains("TestDescriptionUpdated", responseString);
                Assert.Contains("<a href=\"/Products/StatusShary/" + productId + "\">UnShary</a>", responseString);
                Assert.DoesNotContain("<a href=\"/Products/StatusShary/" + productId + "\">Shary</a>", responseString);
                #endregion

                #region Change status
                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Common.ChangeStatus(productId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Product.Common.ChangeStatus(productId), antiForgeryValues)
                              .Build();

                response = await productClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Product.Get.GetProducts, response.Headers.Location.OriginalString);

                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.GetDetails(productId));

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                Assert.DoesNotContain("<a href=\"/Products/StatusShary/" + productId + "\">UnShary</a>", responseString);
                Assert.Contains("<a href=\"/Products/StatusShary/" + productId + "\">Shary</a>", responseString);
                #endregion

                #region Delete product
                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Common.DeleteProduct(productId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Product.Common.DeleteProduct(productId), antiForgeryValues)
                              .Build();

                response = await productClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Product.Get.GetProducts, response.Headers.Location.OriginalString);

                Func <Task> act = async() =>
                {
                    await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.GetDetails(productId));
                };
                act.Should().ThrowExactly <ArgumentException>().WithMessage("Product with Id 1 not exist (Parameter 'productId')");
                #endregion
            }
        }
Пример #10
0
        public async Task Post_Create_Update_ChangeDuration_AddComment_Reject_Confirm_Return_All_Ok()
        {
            using (TestServer sharethingsServer = new ShareThingsScenarioBase().CreateServer())
            {
                HttpClient productClient = shareThingsScenarioBase.CreateHttpClientLender(sharethingsServer);

                #region Create product
                HttpResponseMessage response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.CreateProduct);

                var antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                DateTime productStartDate = DateTime.Now.AddDays(-6);
                DateTime productEndDate   = DateTime.Now.AddDays(26);

                HttpRequestMessage postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Product.Post.CreateProduct, antiForgeryValues)
                                                 .Set("Name", "TestName")
                                                 .Set("Description", "TestDescriptionCreated")
                                                 .Set("Type", "TestType")
                                                 .Set("Subtype", "TestSubtype")
                                                 .Set("Start", productStartDate.ToString("yyyy-MM-dd HH:mm:ss"))
                                                 .Set("End", productEndDate.ToString("yyyy-MM-dd HH:mm:ss"))
                                                 .Build();

                response = await productClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Product.Get.GetProducts, response.Headers.Location.OriginalString);

                // Get Id product
                response = await productClient.GetAsync(ShareThingsScenarioBase.Product.Get.GetProducts);

                string responseString = await response.Content.ReadAsStringAsync();

                string key       = "/Products/Edit/";
                int    index     = responseString.IndexOf(key);
                int    productId = Convert.ToInt32(responseString.Substring(index + key.Length, 1));
                #endregion

                HttpClient borrowClient = shareThingsScenarioBase.CreateHttpClientBorrower(sharethingsServer);

                #region Create borrow 1
                response = await borrowClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.CreateBorrow(productId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                DateTime borrowDateStart = DateTime.Now.AddDays(-3);
                DateTime borrowDateEnd   = DateTime.Now.AddDays(23);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Borrow.Post.CreateBorrow, antiForgeryValues)
                              .Set("Borrow.ProductId", productId.ToString())
                              .Set("Borrow.ProductStart", productStartDate.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.ProductEnd", productEndDate.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.Start", borrowDateStart.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.End", borrowDateEnd.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Build();

                response = await borrowClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Borrow.Get.GetBorrows, response.Headers.Location.OriginalString);

                // Get borrow Id
                response = await productClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.GetBorrows);

                responseString = await response.Content.ReadAsStringAsync();

                key   = "/Borrows/Details/";
                index = responseString.IndexOf(key);
                int borrowId = Convert.ToInt32(responseString.Substring(index + key.Length, 1));
                #endregion

                #region Owner Product Details
                response = await productClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.GetOwnerDetails(borrowId));

                response.EnsureSuccessStatusCode();
                #endregion

                #region Change duration borrow
                DateTime borrowDateStartUpdated = DateTime.Now.AddDays(-2);
                DateTime borrowDateEndUpdated   = DateTime.Now.AddDays(20);

                response = await borrowClient.GetAsync(ShareThingsScenarioBase.Borrow.Common.EditBorrow(borrowId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Borrow.Common.EditBorrow(borrowId), antiForgeryValues)
                              .Set("id", borrowId.ToString())
                              .Set("Borrow.BorrowId", borrowId.ToString())
                              .Set("Borrow.ProductId", productId.ToString())
                              .Set("Borrow.ProductStart", productStartDate.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.ProductEnd", productEndDate.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.Start", borrowDateStartUpdated.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.End", borrowDateEndUpdated.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Build();

                response = await borrowClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Borrow.Get.GetBorrows, response.Headers.Location.OriginalString);

                // Get detail borrowId
                response = await productClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.GetDetails(borrowId));

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                Assert.DoesNotContain(borrowDateStart.ToString("yyyy-MM-dd"), responseString);
                Assert.DoesNotContain(borrowDateEnd.ToString("yyyy-MM-dd"), responseString);
                Assert.Contains(borrowDateStartUpdated.ToString("yyyy-MM-dd"), responseString);
                Assert.Contains(borrowDateEndUpdated.ToString("yyyy-MM-dd"), responseString);
                #endregion

                #region Add comment
                string comment = "New comment";

                response = await borrowClient.GetAsync(ShareThingsScenarioBase.Borrow.Common.AddComment(borrowId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Borrow.Common.AddComment(borrowId), antiForgeryValues)
                              .Set("id", borrowId.ToString())
                              .Set("Borrow.BorrowId", borrowId.ToString())
                              .Set("Comment.Text", comment)
                              .Build();

                response = await borrowClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.OK, response.StatusCode);

                // Get detail borrowId
                response = await productClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.GetDetails(borrowId));

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                Assert.Contains(comment, responseString);
                #endregion

                #region Set score
                int score = 5;

                response = await borrowClient.GetAsync(ShareThingsScenarioBase.Borrow.Common.Score(borrowId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Borrow.Common.Score(borrowId), antiForgeryValues)
                              .Set("id", borrowId.ToString())
                              .Set("Borrow.BorrowId", borrowId.ToString())
                              .Set("Borrow.Score", score.ToString())
                              .Build();

                response = await borrowClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);

                // Get detail borrowId
                response = await productClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.GetDetails(borrowId));

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                Assert.Contains("name=\"Borrow.Score\" value=\"" + score + "\"", responseString);
                #endregion

                #region Reject
                response = await borrowClient.GetAsync(ShareThingsScenarioBase.Borrow.Common.Reject(borrowId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Borrow.Common.Reject(borrowId), antiForgeryValues)
                              .Set("id", borrowId.ToString())
                              .Set("Borrow.BorrowId", borrowId.ToString())
                              .Build();

                response = await borrowClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);

                // Get detail borrowId
                response = await productClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.GetDetails(borrowId));

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                Assert.Contains("Rejected", responseString);
                #endregion

                #region Create borrow 2
                response = await borrowClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.CreateBorrow(productId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Borrow.Post.CreateBorrow, antiForgeryValues)
                              .Set("Borrow.ProductId", productId.ToString())
                              .Set("Borrow.ProductStart", productStartDate.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.ProductEnd", productEndDate.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.Start", borrowDateStart.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Set("Borrow.End", borrowDateEnd.ToString("yyyy-MM-dd HH:mm:ss"))
                              .Build();

                response = await borrowClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);
                Assert.EndsWith(ShareThingsScenarioBase.Borrow.Get.GetBorrows, response.Headers.Location.OriginalString);

                // Get borrow Id
                response = await productClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.GetBorrows);

                responseString = await response.Content.ReadAsStringAsync();

                key      = "/Borrows/Details/";
                index    = responseString.LastIndexOf(key);
                borrowId = Convert.ToInt32(responseString.Substring(index + key.Length, 1));
                #endregion

                #region Confirm
                response = await borrowClient.GetAsync(ShareThingsScenarioBase.Borrow.Common.Confirm(borrowId));

                antiForgeryValues = await AntiForgeryTokenExtractor.ExtractAntiForgeryValues(response);

                postRequest = new HttpRequestMessageBuilder(
                    HttpMethod.Post, ShareThingsScenarioBase.Borrow.Common.Confirm(borrowId), antiForgeryValues)
                              .Set("id", borrowId.ToString())
                              .Set("Borrow.BorrowId", borrowId.ToString())
                              .Build();

                response = await borrowClient.SendAsync(postRequest);

                Assert.Equal(HttpStatusCode.Found, response.StatusCode);

                // Get detail borrowId
                response = await productClient.GetAsync(ShareThingsScenarioBase.Borrow.Get.GetDetails(borrowId));

                response.EnsureSuccessStatusCode();
                responseString = await response.Content.ReadAsStringAsync();

                Assert.Contains("Accepted", responseString);
                #endregion
            }
        }