Esempio n. 1
0
        public void RepeatedSicknessInference()
        {
            CreateTestConfig();
            var store = GetTestStore();
            CreateTestUsers(store);
            CreateTestSickness(store);


            var processor = new InferenceProcessor(new[] { store }, new IInferenceType[] {
                new RepeatedSicknessReasonInferenceType(_typeConfig)
                                       {
                                           Actions = new IInferenceAction[]
                                                         {
                                                             new NotifyManagerAction()
                                                         }}}, MockRepository.GenerateStub<log4net.ILog>());
            processor.Process();
            using (var session = store.OpenSession())
            {
                Assert.AreEqual(session.Query<Common.Inference.Inference>().Count(), 1);
                Assert.AreEqual(session.Query<Notification>().Count(), 1);
            }
        }
Esempio n. 2
0
        public void NoPraiseInferenceInferenceAlreadyMade()
        {
            CreateTestConfig();
            var store = GetTestStore();
            CreateTestUsers(store);
           
            using (var session = store.OpenSession())
            {
                var existingInference = new Common.Inference.Inference
                {
                    Id = IlluminateDatabase.GenerateId<Common.Inference.Inference>(),
                    InferenceTypeName = NoPraiseInferenceType.ThisName,
                    MadeAt = DateTime.Today.AddDays(-1),
                    UserId = _user1.Id
                };
                session.Store(existingInference);
                var praise = new Praise
                {
                    Id = IlluminateDatabase.GenerateId<Praise>(),
                    SubjectUser = _user2.ToSimpleUser(),
                    EventDate = DateTime.Today.AddDays((-1))
                };
                session.Store(praise);
                session.SaveChanges();
            }

            var processor = new InferenceProcessor(new[] { store }, new IInferenceType[] {
                new NoPraiseInferenceType(_typeConfig) 
                                       {
                                           Actions = new IInferenceAction[]
                                                         {
                                                             new NotifyManagerAction()
                                                         }}}, MockRepository.GenerateStub<log4net.ILog>());
            processor.Process();
            using (var session = store.OpenSession())
            {
                Assert.AreEqual(session.Query<Common.Inference.Inference>().Count(), 1);
                Assert.AreEqual(session.Query<Notification>().Count(), 0);
            }
        }