Example #1
0
        public void Execute_Creates_History_Record()
        {
            // Setup
            InitializeTestEntities();

            // Act
            DateTime start = DateTime.Now;

            new EditJobSearchCommand(_unitOfWork).WithJobSearchId(_jobSearch.Id)
            .SetName("New Name")
            .SetDescription("New Description")
            .CalledByUserId(_user.Id)
            .Execute();
            DateTime end = DateTime.Now;

            // Verify
            JobSearch        result  = _unitOfWork.JobSearches.Fetch().Single();
            JobSearchHistory history = result.History.Single();

            Assert.AreEqual("New Name", history.Name, "The history record had an incorrect name");
            Assert.AreEqual("New Description", history.Description, "The history record had an incorrect description");
            Assert.AreEqual(_user, history.AuthoringUser, "The history record had an incorrect author");
            Assert.AreEqual(MJLConstants.HistoryUpdate, history.HistoryAction, "The history record had an incorrect history action value");
            Assert.IsTrue(history.DateModified >= start && history.DateModified <= end, "The history record had an incorrect modification date");
        }
        public void Execute_Creates_History_Record()
        {
            // Setup
            InitializeTestEntities();
            DateTime start, end;

            // Act
            start = DateTime.Now;
            new CreateJobSearchForUserCommand(_serviceFactory.Object).ForUserId(_user.Id)
            .WithName("Test Name")
            .WithDescription("Test Desc")
            .Execute();
            end = DateTime.Now;

            // Verify
            JobSearch        result  = _unitOfWork.JobSearches.Fetch().Single();
            JobSearchHistory history = result.History.Single();

            Assert.AreEqual("Test Name", history.Name, "History record had an incorrect name value");
            Assert.AreEqual("Test Desc", history.Description, "History record had an incorrect description value");
            Assert.AreEqual(_user, history.AuthoringUser, "History record had an incorrect author");
            Assert.AreEqual(MJLConstants.HistoryInsert, history.HistoryAction, "History record had an incorrect history action value");
            Assert.IsTrue(history.DateModified >= start && history.DateModified <= end, "History record had an incorrect modified date value");
        }