public void TestBasicEditCommandHandling()
        {
            var target = new EmployeeAggregate(CreateDataModelMock());

            var cmd = new EmployeeEditCommand() { Arg = CreateExistingEmployeeModel() };

            var results = target.Handle(cmd).ToArray();

            Assert.IsNotNull(results);
            Assert.AreEqual(1, results.Count());

            var empEditedEvent = results.First() as EmployeeEditedEvent;

            Assert.IsNotNull(empEditedEvent);
        }
        public void TestBasicPayCalculation()
        {
            var target = new EmployeeAggregate(CreateDataModelMock());

            var cmd = new EmployeeCreateCommand() { Arg = CreateNewEmployeeModel() };

            var results = target.Handle(cmd).ToArray();

            Assert.IsNotNull(results);
            Assert.AreEqual(1, results.Count());

            var empCreatedEvent = results.First() as EmployeeCreatedEvent;

            Assert.IsNotNull(empCreatedEvent);

            Assert.AreEqual(2000M, empCreatedEvent.Data.GrossPay);
            Assert.AreEqual(38M, empCreatedEvent.Data.Benefits);
            Assert.AreEqual(1962M, empCreatedEvent.Data.NetPay);
        }
        public void TestBasicPayWithDependentCalculation()
        {
            var target = new EmployeeAggregate(CreateDataModelMock());

            var arg = CreateNewEmployeeModel();

            arg.Dependents = new DependentModel[] { new DependentModel() { Name = "OtherGuy" } };

            var cmd = new EmployeeCreateCommand() { Arg = arg };

            var results = target.Handle(cmd).ToArray();

            Assert.IsNotNull(results);
            Assert.AreEqual(1, results.Count());

            var empCreatedEvent = results.First() as EmployeeCreatedEvent;

            Assert.IsNotNull(empCreatedEvent);

            Assert.AreEqual(2000M, empCreatedEvent.Data.GrossPay);
            Assert.AreEqual(57M, empCreatedEvent.Data.Benefits);
            Assert.AreEqual(1943M, empCreatedEvent.Data.NetPay);
        }