Example #1
0
        public void ShouldRetrieveAllExpenseReports()
        {
            new DatabaseTester().Clean();
            var report = new ExpenseReport
            {
                Title       = "TestExpens",
                Description = "This is an ",
                Number      = "123",
                Status      = ExpenseReportStatus.Cancelled
            };
            var report2 = new ExpenseReport
            {
                Title       = "TestExpens",
                Description = "This is an ",
                Number      = "123",
                Status      = ExpenseReportStatus.Cancelled
            };

            using (var context = new StubbedDataContextFactory().GetContext())
            {
                context.AddRange(report, report2);
                context.SaveChanges();
            }

            ListExpenseReportsHandler handler =
                new ListExpenseReportsHandler(new StubbedDataContextFactory().GetContext());
            var expenseReports = handler.Handle(new ListExpenseReportsCommand());

            expenseReports.Length.ShouldBe(2);
            expenseReports.ShouldContain(report);
            expenseReports.ShouldContain(report2);
        }
        public void ShouldResolveAndExecuteAHandler()
        {
            new DatabaseTester().Clean();
            var report = new ExpenseReport
            {
                Title       = "TestExpens",
                Description = "This is an ",
                Number      = "123",
                Status      = ExpenseReportStatus.Cancelled
            };

            using (var context = new StubbedDataContextFactory().GetContext())
            {
                context.AddRange(report);
                context.SaveChanges();
            }

            var container = new DatabaseTester().GetContainer();
            var bus       = container.GetInstance <Bus>();
            var reports   = bus.Send(new ListExpenseReportsCommand());;

            reports.Length.ShouldBe(1);
        }