예제 #1
0
        public void YandexSendPayment_ValidPayment_ReturnsOk()
        {
            // Arrange
            var sender    = _fixture.Merchant.YandexMoneyAccount;
            var testEvent = _fixture.Events[0];
            var email     = Generator.Email();
            var before    = _fixture.Db.Tickets.Count(t => t.Payment.Email == email);

            // Act
            var response = _fixture.Api.SendPayment(
                sender,
                new YandexPaymentLabel(testEvent),
                email,
                testEvent.Roubles,
                testEvent.Roubles - 0.01m
                );

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            AssertWithTimeout.That(
                () => _fixture.Db.Tickets.Count(t => t.Payment.Email == email),
                Is.EqualTo(before + 1)
                );
            AssertWithTimeout.That(() => _fixture.FakeSender.EmailsForAddress(email).Data.Count, Is.EqualTo(1));
        }
예제 #2
0
        public void SendExistBarcode_ReturnsOk()
        {
            // Arrange
            var sender    = _fixture.Merchant.YandexMoneyAccount;
            var testEvent = _fixture.Events[0];
            var email     = Generator.Email();

            _fixture.Api.SendPayment(sender, new YandexPaymentLabel(testEvent), email, testEvent.Roubles, testEvent.Roubles);
            var ticket = _fixture.Db.Tickets.First(t => t.Payment.Email == email);
            var scan   = new BarcodeScan(ticket.Number);

            // Act
            var response = _fixture.Api.VerifyBarcode(scan);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            NHamcrest.XUnit.Assert.That(response.Content, new NotUsed());
            NHamcrest.XUnit.Assert.That(response.Content, new WithConcert("First Test Artist — 9 июля 2019"));

            AssertWithTimeout.That("Ticket should be expired",
                                   () => {
                _fixture.Db.Entry(ticket).State = EntityState.Detached;
                return(_fixture.Db.Find <Ticket>(ticket.Id).Expired);
            },
                                   Is.True());
        }
예제 #3
0
        public void SendBarcode_WithoutBearerToken_ReturnsUnauthorized()
        {
            // Arrange
            var sender    = _fixture.Merchant.YandexMoneyAccount;
            var testEvent = _fixture.Events[0];
            var email     = Generator.Email();

            _fixture.Api.SendPayment(sender, new YandexPaymentLabel(testEvent), email, testEvent.Roubles, testEvent.Roubles);
            var ticket = _fixture.Db.Tickets.First(t => t.Payment.Email == email);
            var scan   = new ManualScan(ticket.Number);

            // Act
            var response = _fixture.Api.VerifyBarcodeWithoutAuth(scan);

            // Assert
            Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
            Assert.Equal(new UnauthorizedAnswer().ToString(), response.Content);
            AssertWithTimeout.That(() => _fixture.Db.Tickets.First(t => t.Payment.Email == email).Expired, Is.False());
        }