public void PropertiesShouldGetAndSetValuesProperly()
        {
            var report = new ExpenseReport();
            Guid guid = Guid.NewGuid();
            var creator = new Employee();
            var assignee = new Employee();
            DateTime auditDate = new DateTime(2000, 1, 1, 8, 0, 0);
            AuditEntry testAudit = new AuditEntry(creator, auditDate, ExpenseReportStatus.Submitted, ExpenseReportStatus.Approved);

            report.Id = guid;
            report.Title = "Title";
            report.Description = "Description";
            report.Status = ExpenseReportStatus.Approved;
            report.Number = "Number";
            report.Submitter = creator;
            report.Approver = assignee;
            report.AddAuditEntry(testAudit);

            Assert.That(report.Id, Is.EqualTo(guid));
            Assert.That(report.Title, Is.EqualTo("Title"));
            Assert.That(report.Description, Is.EqualTo("Description"));
            Assert.That(report.Status, Is.EqualTo(ExpenseReportStatus.Approved));
            Assert.That(report.Number, Is.EqualTo("Number"));
            Assert.That(report.Submitter, Is.EqualTo(creator));
            Assert.That(report.Approver, Is.EqualTo(assignee));
            Assert.That(report.GetAuditEntries()[0].BeginStatus, Is.EqualTo(ExpenseReportStatus.Submitted));
            Assert.That(report.GetAuditEntries()[0].EndStatus, Is.EqualTo(ExpenseReportStatus.Approved));
            Assert.That(report.GetAuditEntries()[0].Date, Is.EqualTo(auditDate));
            Assert.That(report.GetAuditEntries()[0].ArchivedEmployeeName, Is.EqualTo(" "));
        }
        public void ShouldSaveAuditEntries()
        {
            new DatabaseTester().Clean();

            var creator = new Employee("1", "1", "1", "1");
            var assignee = new Employee("2", "2", "2", "2");
            var report = new ExpenseReport();
            report.Submitter = creator;
            report.Approver = assignee;
            report.Title = "foo";
            report.Description = "bar";
            report.ChangeStatus(ExpenseReportStatus.Approved);
            report.Number = "123";
            report.AddAuditEntry(new AuditEntry(creator, DateTime.Now,ExpenseReportStatus.Submitted,
                                                  ExpenseReportStatus.Approved));

            using(ISession session = DataContext.GetTransactedSession())
            {
                session.SaveOrUpdate(creator);
                session.SaveOrUpdate(assignee);
                session.Transaction.Commit();
            }

            IContainer container = DependencyRegistrarModule.EnsureDependenciesRegistered();
            var bus = container.GetInstance<Bus>();
            bus.Send(new ExpenseReportSaveCommand { ExpenseReport = report });

            ExpenseReport rehydratedReport;
            using(ISession session2 = DataContext.GetTransactedSession())
            {
                rehydratedReport = session2.Load<ExpenseReport>(report.Id);
            }

            var x = report.GetAuditEntries()[0];
            var y = rehydratedReport.GetAuditEntries()[0];
            y.EndStatus.ShouldEqual(x.EndStatus);
            y.BeginStatus.ShouldEqual(x.BeginStatus);
            y.EmployeeName.ShouldEqual(x.EmployeeName);
        }
        public void ShouldSaveAuditEntries()
        {
            new DatabaseTester().Clean();

            var creator = new Employee("1", "1", "1", "1");
            var assignee = new Employee("2", "2", "2", "2");
            var order = new ExpenseReport();
            order.Submitter = creator;
            order.Approver = assignee;
            order.Title = "foo";
            order.Description = "bar";
            order.ChangeStatus(ExpenseReportStatus.Approved);
            order.Number = "123";
            order.AddAuditEntry(new AuditEntry(creator, DateTime.Now, ExpenseReportStatus.Submitted,
                                                  ExpenseReportStatus.Approved));

            using (ISession session = DataContext.GetTransactedSession())
            {
                session.SaveOrUpdate(creator);
                session.SaveOrUpdate(assignee);
                session.Transaction.Commit();
            }

            var repository = new ExpenseReportRepository();
            repository.Save(order);

            ExpenseReport rehydratedExpenseReport;
            using (ISession session2 = DataContext.GetTransactedSession())
            {
                rehydratedExpenseReport = session2.Load<ExpenseReport>(order.Id);
            }

            var x = order.GetAuditEntries()[0];
            var y = rehydratedExpenseReport.GetAuditEntries()[0];
            Assert.That(x.BeginStatus, Is.EqualTo(y.BeginStatus));
        }