Пример #1
0
 public static void ClassInit(TestContext textContext)
 {
     controller               = new SearchBookController(SearchBookServiceGenerator.GetMockService().Object, UserDemandServiceGenerator.GetMockService().Object);
     controller.Request       = new HttpRequestMessage();
     controller.Configuration = new HttpConfiguration();
     AutoMapperInit.BuildMap();
 }
Пример #2
0
        public async Task DemandBook_ValidInput_Add_Success()
        {
            // Arrange
            var exisitngCount = UserDemandServiceGenerator.GetUserDemandDataCollection().Count;
            var bookId        = SearchBookServiceGenerator.GetDataCollection()[0].Id;
            var userName      = UserManagerGenerator.GetDataCollection()[2].UserName;
            var requestModel  = new DemandBookRequestModel {
                BookId = bookId.ToString(), UserName = userName
            };
            // Act
            var     response        = controller.Post(requestModel);
            dynamic responseContent = await response.Content.ReadAsAsync <ExpandoObject>();

            // Assert
            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK);
            Assert.IsTrue(exisitngCount + 1 == UserDemandServiceGenerator.GetUserDemandDataCollection().Count);
        }
Пример #3
0
        public async Task GetBooks_ValidSearchParam_Returns_Records()
        {
            // Arrange
            var userName = UserManagerGenerator.GetDataCollection()[0].UserName;
            var author   = SearchBookServiceGenerator.GetDataCollection()[0].Authors.FirstOrDefault();

            var searchParam = new SearchBookViewModel {
                UserName = userName, Author = author
            };
            // Act
            var     response        = controller.Get(searchParam);
            dynamic responseContent = await response.Content.ReadAsAsync <ExpandoObject>();

            var selectedItems = responseContent.ViewModels;

            // Assert
            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK);
            Assert.IsTrue(selectedItems.Count > 0);
        }
Пример #4
0
 public void TestInit()
 {
     UserDemandServiceGenerator.ResetUserDemandDataCollection();
     SearchBookServiceGenerator.ResetBookDataCollection();
     UserManagerGenerator.ResetDataCollection();
 }