Exemplo n.º 1
0
        public void Create_DataCorrect_InvoiceCreated()
        {
            var user = UserFaker.Create();

            var project = ProjectFaker.Create();

            var amount = Rand.SmallDecimal();

            CurrencyWalletFaker.Create(CurrencyType.BitCoin);

            var result = new Browser(new DefaultNancyBootstrapper())
                         .Post("/api/v1/invoice/new", with => {
                with.HttpRequest();
                with.Query("api_token", Jwt.FromUserId(user.id));
                with.Query("entity_guid", project.guid);
                with.Query("entity_type", EntityType.Project.ToString());
                with.Query("amount", amount.ToString(CultureInfo.InvariantCulture));
                with.Query("currency_type", CurrencyType.BitCoin.ToString());
            }).Result;

            Assert.AreEqual(1, global::App.DL.Model.Funding.Invoice.GetActiveForUser(user).Length);
            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);

            var jsonData = JObject.Parse(result.Body.AsString())["data"]["invoice"];

            Assert.AreEqual(project.guid, jsonData.Value <string>("entity_guid") ?? "");
            Assert.AreEqual(amount, jsonData.Value <decimal?>("amount") ?? 0);
        }
Exemplo n.º 2
0
        public void Create_DataCorrect_GotInvoice()
        {
            var user   = UserFaker.Create();
            var result = InvoiceRepository.Create(
                user,
                Rand.Int(),
                EntityType.Project,
                0.0001M * Rand.SmallInt(),
                CurrencyType.BitCoin,
                InvoiceStatus.Created,
                CurrencyWalletFaker.Create(CurrencyType.BitCoin)
                );

            Assert.NotNull(result);
            Assert.AreEqual(user.id, result.User().id);
        }