예제 #1
0
        public async Task UpdateTask_Success()
        {
            var dataGenerationResult = _trackingContext.AddTestData <Domain.Entities.Task>(5);
            var selectedId           = dataGenerationResult.Item2[1];
            var updatedModel         = new Domain.Models.Task {
                Id = selectedId, Name = "NewTaskName"
            };
            var request = new UpdateTaskRequest(selectedId, updatedModel);

            var handler = new UpdateTaskRequestHandler(_trackingContext, Mapper.Instance);
            var result  = await handler.Handle(request, default(CancellationToken));

            Assert.AreEqual(Unit.Value, result);
        }
        public async Task SaveTransaction_Success()
        {
            var expectedResultCount = 1;

            var dataGenerationResult1 = _trackingContext.AddTestData <Domain.Entities.Ledger>(expectedResultCount);
            var dataGenerationResult2 = _trackingContext.AddTestData <Domain.Entities.Transaction>(expectedResultCount);

            Assert.IsTrue(dataGenerationResult1.Item1);
            Assert.IsTrue(dataGenerationResult2.Item1);

            var ledgerId = dataGenerationResult1.Item2[0];

            var model = new Domain.Models.Transaction
            {
                Description       = "Test",
                TransactionDate   = DateTime.UtcNow,
                AccountingEntries = new List <Domain.Models.AccountingEntry>
                {
                    new Domain.Models.AccountingEntry
                    {
                        Amount    = 100,
                        Side      = Domain.Models.AccountingEntry.EntrySide.Credit,
                        AccountId = 1
                    },
                    new Domain.Models.AccountingEntry
                    {
                        Amount    = 100,
                        Side      = Domain.Models.AccountingEntry.EntrySide.Debit,
                        AccountId = 1
                    }
                }
            };
            var request = new SaveTransactionRequest(ledgerId, model);
            var handler = new SaveTransactionRequestHandler(_trackingContext, Mapper.Instance);
            var result  = await handler.Handle(request, default(CancellationToken));

            Assert.AreEqual(result, Unit.Value);
        }
예제 #3
0
        public async Task SaveMainAccountGroup_Success()
        {
            var expectedResultCount = 1;

            var dataGenerationResult = _trackingContext.AddTestData <Domain.Entities.Ledger>(expectedResultCount);

            Assert.IsTrue(dataGenerationResult.Item1);

            var ledgerId = dataGenerationResult.Item2[0];
            var model    = new Domain.Models.MainAccountGroup {
                Number = 1, Name = "Tillgångar"
            };
            var request = new SaveMainAccountGroupRequest(ledgerId, model);

            var handler = new SaveMainAccountGroupRequestHandler(_trackingContext, Mapper.Instance);
            var result  = await handler.Handle(request, default(CancellationToken));

            Assert.AreEqual(result, Unit.Value);
        }
예제 #4
0
        public async Task SaveAccount_Success()
        {
            var expectedResultCount = 1;

            var dataGenerationResult1 = _trackingContext.AddTestData <Domain.Entities.SubAccountGroup>(expectedResultCount);

            Assert.IsTrue(dataGenerationResult1.Item1);

            var ledgerSubAccountGroupId = dataGenerationResult1.Item2[0];

            var model = new Domain.Models.Account {
                Number = 1931, Name = "Företagskonto"
            };
            var request = new SaveAccountRequest(ledgerSubAccountGroupId, model);

            var handler = new SaveAccountRequestHandler(_trackingContext, Mapper.Instance);
            var result  = await handler.Handle(request, default(CancellationToken));

            Assert.AreEqual(result, Unit.Value);
        }