Ejemplo n.º 1
0
        public void ShouldPersist()
        {
            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.Add(report);
                context.SaveChanges();
            }

            ExpenseReport rehydratedExpenseReport;

            using (var context = new StubbedDataContextFactory().GetContext())
            {
                rehydratedExpenseReport = context.Find <ExpenseReport>(report.Id);
            }

            rehydratedExpenseReport.Title.ShouldBe(report.Title);
            rehydratedExpenseReport.Description.ShouldBe(report.Description);
            rehydratedExpenseReport.Number.ShouldBe(report.Number);
            rehydratedExpenseReport.Status.ShouldBe(report.Status);
        }
Ejemplo n.º 2
0
        public void ShouldPersistExportReportFact()
        {
            new DatabaseTester().Clean();
            var employee = new Employee("somethingelse", "Jeffrey", "Palermo", "jeffrey @ clear dash measure.com");

            employee.Id = Guid.NewGuid();
            var report = new ExpenseReport
            {
                Number    = "123",
                Status    = ExpenseReportStatus.Draft,
                Submitter = employee
            };

            DateTime          setDate           = new DateTime(2015, 1, 1);
            ExpenseReportFact expenseReportFact = new ExpenseReportFact(report, setDate);

            var command = new AddExpenseReportFactCommand(expenseReportFact);

            IContainer container = DependencyRegistrarModule.EnsureDependenciesRegistered();
            var        bus       = container.GetInstance <Bus>();

            bus.Send(command);

            ExpenseReportFact reHydratedExpenseReportFact;

            using (EfCoreContext session = new StubbedDataContextFactory().GetContext())
            {
                reHydratedExpenseReportFact = session.Find <ExpenseReportFact>(expenseReportFact.Id);
            }

            reHydratedExpenseReportFact.Approver.ShouldEqual(expenseReportFact.Approver);
            reHydratedExpenseReportFact.Number.ShouldEqual(expenseReportFact.Number);
            reHydratedExpenseReportFact.Status.ShouldEqual(expenseReportFact.Status);
            reHydratedExpenseReportFact.Submitter.ShouldEqual(expenseReportFact.Submitter);
            reHydratedExpenseReportFact.TimeStamp.ShouldEqual(expenseReportFact.TimeStamp);
            reHydratedExpenseReportFact.Total.ShouldEqual(expenseReportFact.Total);
        }
        public void ShouldAddFact()
        {
            new DatabaseTester().Clean();

            var creator       = new Employee("1", "1", "1", "1");
            var assignee      = new Employee("2", "2", "2", "2");
            var expenseReport = new ExpenseReport
            {
                Submitter   = creator,
                Approver    = assignee,
                Title       = "foo",
                Description = "bar",
                Number      = "123"
            };

            expenseReport.ChangeStatus(ExpenseReportStatus.Approved);
            ExpenseReportFact expenseReportFact = new ExpenseReportFact(expenseReport, new DateTime(2012, 1, 1));


            using (EfCoreContext context = new StubbedDataContextFactory().GetContext())
            {
                context.Add(expenseReportFact);
                context.SaveChanges();
            }

            using (EfCoreContext context = new StubbedDataContextFactory().GetContext())
            {
                var reportFact = context.Find <ExpenseReportFact>(expenseReportFact.Id);

                reportFact.Total.ShouldEqual(expenseReportFact.Total);
                reportFact.TimeStamp.ShouldEqual(expenseReportFact.TimeStamp);
                reportFact.Number.ShouldEqual(expenseReportFact.Number);
                reportFact.Status.ShouldEqual(expenseReportFact.Status);
                reportFact.Submitter.ShouldEqual(expenseReportFact.Submitter);
                reportFact.Approver.ShouldEqual(expenseReportFact.Approver);
            }
        }
Ejemplo n.º 4
0
        public void EfCoreMappingShouldPersist()
        {
            new DatabaseTester().Clean();

            var one = new Employee("1", "first1", "last1", "email1");

            using (EfCoreContext context = new StubbedDataContextFactory().GetContext())
            {
                context.Add(one);
                context.SaveChanges();
            }

            Employee rehydratedEmployee;

            using (EfCoreContext context = new StubbedDataContextFactory().GetContext())
            {
                rehydratedEmployee = context.Find <Employee>(one.Id);
            }

            rehydratedEmployee.UserName.ShouldEqual(one.UserName);
            rehydratedEmployee.FirstName.ShouldEqual(one.FirstName);
            rehydratedEmployee.LastName.ShouldEqual(one.LastName);
            rehydratedEmployee.EmailAddress.ShouldEqual(one.EmailAddress);
        }