public void VoucherStoreTest(string dt, VoucherType type) { var voucher1 = VoucherDataProvider.Create(dt, type); m_Adapter.Upsert(voucher1); Assert.NotNull(voucher1.ID); var voucher2 = m_Adapter.SelectVouchers(VoucherQueryUnconstrained.Instance).Single(); Assert.Equal(voucher1, voucher2, new VoucherEqualityComparer()); var voucher3 = m_Adapter.SelectVoucher(voucher1.ID); Assert.Equal(voucher1, voucher3, new VoucherEqualityComparer()); Assert.True(m_Adapter.DeleteVoucher(voucher1.ID)); Assert.False(m_Adapter.DeleteVoucher(voucher1.ID)); Assert.False(m_Adapter.SelectVouchers(VoucherQueryUnconstrained.Instance).Any()); }
public async Task VoucherStoreTest(string dt, VoucherType type) { var voucher1 = VoucherDataProvider.Create(dt, type); Assert.True(await m_Adapter.Upsert(voucher1)); Assert.NotNull(voucher1.ID); voucher1.Remark = "whatever"; Assert.True(await m_Adapter.Upsert(voucher1)); var voucher2 = await m_Adapter.SelectVouchers(VoucherQueryUnconstrained.Instance).SingleAsync(); Assert.Equal(voucher1, voucher2, new VoucherEqualityComparer()); var voucher3 = await m_Adapter.SelectVoucher(voucher1.ID); Assert.Equal(voucher1, voucher3, new VoucherEqualityComparer()); Assert.True(await m_Adapter.DeleteVoucher(voucher1.ID)); Assert.False(await m_Adapter.DeleteVoucher(voucher1.ID)); Assert.False(await m_Adapter.SelectVouchers(VoucherQueryUnconstrained.Instance).AnyAsync()); }
public void VoucherStoreTest(string dt, VoucherType type) { var voucher1 = new Voucher { Date = dt.ToDateTime(), Type = type, Remark = "tt", Details = new List <VoucherDetail> { new VoucherDetail { User = "******", Currency = "CNY", Title = 1001, Content = "asdf", Fund = 123.45 }, new VoucherDetail { User = "******", Currency = "USD", Title = 1002, SubTitle = 12, Fund = -123.45, Remark = "qwer" } } }; m_Adapter.Upsert(voucher1); var voucher2 = m_Adapter.SelectVouchers(VoucherQueryUnconstrained.Instance).Single(); Assert.Equal(voucher1, voucher2, new VoucherEqualityComparer()); var voucher3 = m_Adapter.SelectVoucher(voucher1.ID); Assert.Equal(voucher1, voucher3, new VoucherEqualityComparer()); Assert.True(m_Adapter.DeleteVoucher(voucher1.ID)); Assert.False(m_Adapter.DeleteVoucher(voucher1.ID)); Assert.False(m_Adapter.SelectVouchers(VoucherQueryUnconstrained.Instance).Any()); }
public SubtotalTest() { m_Adapter = Facade.Create("mongodb://localhost/accounting-test"); m_Adapter.DeleteVouchers(VoucherQueryUnconstrained.Instance); m_Adapter.Upsert( new Voucher { Date = new DateTime(2016, 12, 31, 0, 0, 0, DateTimeKind.Utc), Remark = "xrmk1", Details = new List <VoucherDetail> { new VoucherDetail { Currency = "JPY", Title = 1234, SubTitle = 56, Content = "cnt1", Fund = 123.45, Remark = "rmk1" }, new VoucherDetail { Currency = "JPY", Title = 6541, SubTitle = 98, Content = "cnt1", Fund = -123.45, Remark = "rmk2" } } }); m_Adapter.Upsert( new Voucher { Date = new DateTime(2017, 02, 01, 0, 0, 0, DateTimeKind.Utc), Remark = "xrmk2", Details = new List <VoucherDetail> { new VoucherDetail { Currency = "JPY", Title = 1234, SubTitle = 56, Content = "cnt1", Fund = 78.53, Remark = "rmk1" }, new VoucherDetail { Currency = "JPY", Title = 6541, SubTitle = 98, Content = "cnt1", Fund = -78.53, Remark = "rmk2" }, new VoucherDetail { Currency = "USD", Title = 1234, SubTitle = 56, Content = "cnt2", Fund = 66.66, Remark = "rmk1" }, new VoucherDetail { Currency = "USD", Title = 6541, SubTitle = 98, Content = "cnt2", Fund = -66.66, Remark = "rmk2" } } }); }
public SubtotalTest() { m_Adapter = Facade.Create(db: "accounting-test"); m_Adapter.DeleteVouchers(VoucherQueryUnconstrained.Instance); m_Adapter.Upsert( new Voucher { Date = new DateTime(2016, 12, 31, 0, 0, 0, DateTimeKind.Utc), Remark = "xrmk1", Details = new List <VoucherDetail> { new VoucherDetail { User = "******", Currency = "JPY", Title = 1234, SubTitle = 56, Content = "cnt1", Fund = 123.45, Remark = "rmk1", }, new VoucherDetail { User = "******", Currency = "JPY", Title = 6541, SubTitle = 98, Content = "cnt1", Fund = -123.45, Remark = "rmk2", }, }, }); m_Adapter.Upsert( new Voucher { Date = new DateTime(2017, 02, 01, 0, 0, 0, DateTimeKind.Utc), Remark = "xrmk2", Details = new List <VoucherDetail> { new VoucherDetail { User = "******", Currency = "JPY", Title = 1234, SubTitle = 56, Content = "cnt1", Fund = 78.53, Remark = "rmk1", }, new VoucherDetail { User = "******", Currency = "JPY", Title = 6541, SubTitle = 98, Content = "cnt1", Fund = -78.53, Remark = "rmk2", }, new VoucherDetail { User = "******", Currency = "USD", Title = 1234, SubTitle = 56, Content = "cnt2", Fund = 66.66, Remark = "rmk1", }, new VoucherDetail { User = "******", Currency = "USD", Title = 6541, SubTitle = 98, Content = "cnt2", Fund = -66.66, Remark = "rmk2", }, new VoucherDetail { User = "******", Currency = "EUR", Title = 2333, Fund = 114514, }, }, }); ClientUser.Set("b1"); }
protected override void PrepareVoucher(Voucher voucher) => m_Adapter.Upsert(voucher);