public async Task SearchAsync_PageForwardAsync_PageBackAsync()
        {
            var page1 = PageMaker.GetExpectedPage(
                data: UomTestData.GetUomsArray(),
                searchText: string.Empty,
                skip: 0,
                take: 20
                );
            var expectedPage1 = CollectionPageDataMaker.GetExpectedPage(page1, "http://localhost/api");

            var page2 = PageMaker.GetExpectedPage(
                data: UomTestData.GetUomsArray(),
                searchText: string.Empty,
                skip: 20,
                take: 20
                );
            var expectedPage2 = CollectionPageDataMaker.GetExpectedPage(page2, "http://localhost/api");

            CollectionPageViewModel <Uom> viewModel = new ViewModelTestBuilder <Uom>()
                                                      .SetConstructor_Title("Uoms")
                                                      .DeleteService_NotCalled()
                                                      .Then_NewPageService_ReadPageAsync("", expectedPage1)
                                                      .Then_ReadPageService_PageForwardAsync(expectedPage2)
                                                      .Then_ReadPageService_PageBackAsync(expectedPage1);
            await viewModel.SearchAsync("");

            Assert.True(CollectionPageViewModelChecker.Check(expectedPage1, viewModel, UomEqual.Check));
            await viewModel.PageForwardAsync();

            Assert.True(CollectionPageViewModelChecker.Check(expectedPage2, viewModel, UomEqual.Check));
            await viewModel.PageBackAsync();

            Assert.True(CollectionPageViewModelChecker.Check(expectedPage1, viewModel, UomEqual.Check));
        }
        public async Task GetSecondPageOfUoms()
        {
            var connection = new SqliteConnection("DataSource=devicedb;Mode=Memory;Cache=Shared");

            try
            {
                var testData = UomTestData.GetUomsArray();
                new DbInitializer().Initialize(connection, GetPropertyContext, UomTestData.GetInitialData());
                var testReadClient = GetTestReadClient();
                var skip           = 20;
                var take           = 20;
                var searchText     = "";
                var endpoint       = $"{EndpointBase}/lrp/uoms?searchText={WebUtility.UrlEncode(searchText)}&skip={skip}&take={take}";
                var httpMessage    = GetRequestWithToken(HttpMethod.Get, endpoint, GoodClaimsList);
                var response       = await testReadClient.SendAsync(httpMessage);

                Assert.True(response.IsSuccessStatusCode);
                var jsonString = await response.Content.ReadAsStringAsync();

                var actualItems  = JsonConvert.DeserializeObject <List <Uom> >(jsonString);
                var expectedPage = PageMaker.GetExpectedPage(testData, searchText, skip, take);
                Assert.True(PageEqual.CheckItemsOnly(expectedPage, actualItems, UomEqual.Check));
            }
            finally
            {
                connection.Close();
            }
        }
예제 #3
0
        public async Task ReadPageAsync()
        {
            var url  = "http://abc.com/api";
            var page = PageMaker.GetExpectedPage(
                data: UomTestData.GetUomsArray(),
                searchText: string.Empty,
                skip: 0,
                take: 20
                );
            var expectedResponse           = CollectionPageHttpResponseMaker.GetExpectedResponse(page, url);
            var expectedData               = CollectionPageDataMaker.GetExpectedPage(page, url);
            HttpRequestMessage sentMessage = null;
            var httpService  = new Mock <IHttpReadService>(MockBehavior.Strict);
            var deserializer = new Mock <IContentDeserializer>(MockBehavior.Strict);
            var sequence     = new MockSequence();

            httpService
            .InSequence(sequence)
            .Setup(h => h.SendAsync(It.IsAny <HttpRequestMessage>()))
            .ReturnsAsync(expectedResponse)
            .Callback <HttpRequestMessage>((request) => sentMessage = request);
            deserializer
            .InSequence(sequence)
            .Setup(d => d.DeserializeAsync <ImmutableList <Uom> >(expectedResponse.Content as StringContent))
            .ReturnsAsync(expectedData.Items as ImmutableList <Uom>);

            var uut        = new ReadPageServiceBuildRequest <Uom>(httpService.Object, deserializer.Object);
            var actualData = await uut.ReadPageAsync(url);

            Assert.NotNull(sentMessage);
            Assert.AreEqual(url, sentMessage.RequestUri.ToString());
            Assert.AreEqual(sentMessage.Method, HttpMethod.Get);
            Assert.True(CollectionPageDataEqual.Check(expectedData, actualData, UomEqual.Check));
        }
예제 #4
0
 public PageServiceImpl(IHostingEnvironment hostingEnvironment, PageRepository pageRepo, TransactionManager transactionManager, PageMaker pageMaker)
 {
     _pageRepo           = pageRepo;
     _transactionManager = transactionManager;
     _pageMaker          = pageMaker;
     _hostingEnvironment = hostingEnvironment;
 }
        public IExceptionHandler CreateObject(params object[] args)
        {
            IPageMaker pageMaker = PageMaker.CreateObject(args);

            return(new PageMakerExceptionHandler(pageMaker)
            {
                LogException = Log
            });
        }
        public async Task GetPageNotFound()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            try
            {
                var testData = UomTestData.GetUomsArray();
                new DbInitializer().Initialize(connection, GetPropertyContext, UomTestData.GetInitialData());
                using (var context = GetPropertyContext(connection))
                {
                    var uomRepository = new UomReadRepository(context);
                    var expectedPage  = PageMaker.GetExpectedPage <Uom>(testData, "", 1000, 20);
                    var actualPage    = await uomRepository.GetAsync("", 1000, 20) as Page <Uom>;

                    Assert.True(PageEqual.Check(expectedPage, actualPage, UomEqual.Check));
                }
            }
            finally
            {
                connection.Close();
            }
        }
        public async Task DeleteAsync()
        {
            var page = PageMaker.GetExpectedPage(
                data: UomTestData.GetUomsArray(),
                searchText: string.Empty,
                skip: 0,
                take: 20
                );
            var expectedPage = CollectionPageDataMaker.GetExpectedPage(page, "http://localhost/api");

            CollectionPageViewModel <Uom> viewModel = new ViewModelTestBuilder <Uom>()
                                                      .SetConstructor_Title("Uoms")
                                                      .Then_NewPageService_ReadPageAsync("", expectedPage)
                                                      .Then_DeleteService_DeleteItemAsync(1001)
                                                      .Then_ReadPageService_RefreshCurrentPageAsync(expectedPage);

            await viewModel.SearchAsync("");

            Assert.True(CollectionPageViewModelChecker.Check(expectedPage, viewModel, UomEqual.Check));
            await viewModel.DeleteAsync(new Uom().WithId(1001));

            Assert.True(CollectionPageViewModelChecker.Check(expectedPage, viewModel, UomEqual.Check));
        }
예제 #8
0
 public static void Run()
 {
     PageMaker.makeWelcomePage("*****@*****.**", "welcome.html");
 }
예제 #9
0
 public static void Main(string[] args)
 {
     PageMaker.MakeWelcomePage("*****@*****.**", "welcome.html");
 }
예제 #10
0
 public static void Main(string[] args)
 {
     PageMaker.MakeWelcomePage("*****@*****.**", "welcome.html");
 }