示例#1
0
        public async Task Has_Order_List()
        {
            // Arrange
            var appSettings = new TestAppSettings();
            var ve          = new Services.TicketGuardianConnectionService(appSettings.Value, new System.Net.Http.HttpClient());
            // Act
            var result = await ve.GetOrders();

            // Assert
            var vr = Assert.IsType <Models.PagedListModel <Models.OrderModel> >(result);

            Assert.NotNull(vr);
            Assert.NotNull(vr.Results);
        }
        public async Task Post_Order()
        {
            // Arrange
            var appSettings = new TestAppSettings();
            var ve          = new Services.TicketGuardianConnectionService(appSettings.Value, new System.Net.Http.HttpClient());
            var orderModel  = CreateTestOrderModel();

            // Act
            var result = await ve.PostTicketOrder(orderModel);

            // Assert
            var vr = Assert.IsType <Models.TicketOrderModel>(result);

            Assert.NotNull(vr);
            //Assert.Equal(vr.InsurancePolicies.Count, orderModel.Tickets.Count);
        }
        public async Task Bad_Public_Key(string badPublicKey)
        {
            // Arrange
            var appSettings = new TestAppSettings();

            appSettings.Value.PublicKey = badPublicKey;
            var ve    = new TicketGuardianTestConnectionService(appSettings.Value, new System.Net.Http.HttpClient());
            var error = new TicketGuardianException(HttpStatusCode.Unauthorized, new Models.ErrorResponseModel(), "");

            // Act
            try
            {
                var result = await ve.GetAuthenticationToken();
            }
            catch (TicketGuardianException ex)
            {
                error = ex;
            }

            // Assert
            Assert.Equal(HttpStatusCode.BadRequest, error.HttpStatusCode);
            Assert.Equal("Bad Public Key or Secret Key.", error.Message);
        }