예제 #1
0
        public void Handle(ProcessRiskCapture message)
        {
            GreenLogger.Log("Processing risk capture");

            using (repository.StartUnitOfWork())
            {
                var mapId = new MapId();
                var map   = repository.Get <Map>(mapId);
                map.ExtractMapFromRequest(message.Request);

                var captureId = RiskCaptureId.Parse(message.Request.ToXDocument().GetHeader().SequenceId.Value);
                var capture   = repository.Get <RiskCapture>(captureId);
                capture.ExtractCaptureFromRequest(captureId, message.Request, map);
            }
        }
        public void Can_Create_And_Get_By_Id_Empty_lang()
        {
            int contentId = CreateTestData("en-AU", out ContentType ct);

            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                DomainRepository repo = CreateRepository(provider);

                IContent content = DocumentRepository.Get(contentId);

                var domain = (IDomain) new UmbracoDomain("test.com")
                {
                    RootContentId = content.Id
                };
                repo.Save(domain);

                // re-get
                domain = repo.Get(domain.Id);

                Assert.NotNull(domain);
                Assert.IsTrue(domain.HasIdentity);
                Assert.Greater(domain.Id, 0);
                Assert.AreEqual("test.com", domain.DomainName);
                Assert.AreEqual(content.Id, domain.RootContentId);
                Assert.IsFalse(domain.LanguageId.HasValue);
            }
        }
        public void Can_Delete()
        {
            int contentId = CreateTestData("en-AU", out ContentType ct);

            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                DomainRepository repo = CreateRepository(provider);

                ILanguage lang    = LanguageRepository.GetByIsoCode("en-AU");
                IContent  content = DocumentRepository.Get(contentId);

                var domain = (IDomain) new UmbracoDomain("test.com")
                {
                    RootContentId = content.Id, LanguageId = lang.Id
                };
                repo.Save(domain);

                repo.Delete(domain);

                // re-get
                domain = repo.Get(domain.Id);

                Assert.IsNull(domain);
            }
        }
        public void Can_Update()
        {
            int contentId1 = CreateTestData("en-AU", out ContentType ct);

            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                DomainRepository repo = CreateRepository(provider);

                IContent content1 = DocumentRepository.Get(contentId1);

                // more test data
                ILanguage lang1          = LanguageRepository.GetByIsoCode("en-AU");
                var       globalSettings = new GlobalSettings();
                var       lang2          = new Language("es", "Spanish");
                LanguageRepository.Save(lang2);
                var content2 = new Content("test", -1, ct)
                {
                    CreatorId = 0, WriterId = 0
                };
                DocumentRepository.Save(content2);

                var domain = (IDomain) new UmbracoDomain("test.com")
                {
                    RootContentId = content1.Id, LanguageId = lang1.Id
                };
                repo.Save(domain);

                // re-get
                domain = repo.Get(domain.Id);

                domain.DomainName    = "blah.com";
                domain.RootContentId = content2.Id;
                domain.LanguageId    = lang2.Id;
                repo.Save(domain);

                // re-get
                domain = repo.Get(domain.Id);

                Assert.AreEqual("blah.com", domain.DomainName);
                Assert.AreEqual(content2.Id, domain.RootContentId);
                Assert.AreEqual(lang2.Id, domain.LanguageId);
                Assert.AreEqual(lang2.IsoCode, domain.LanguageIsoCode);
            }
        }
예제 #5
0
 public void Handle(WithdrawMoneyFromAccount message)
 {
     using (repository.StartUnitOfWork())
     {
         repository
         .Get <BankAccount>(BankAccountId.FromAccountNumber(message.AccountNumber))
         .When(message);
     }
 }
 public void ShouldThrowExceptionWhenNoDomainEventExistForAnAggregate()
 {
     var id = Guid.NewGuid();
     var events = new List<DomainEvent>();
     var fakeEventStore = MockRepository.GenerateMock<IEventStore>();
     fakeEventStore.Stub(x => x.GetEventsForAggregate<EmptyDomainObject>(id)).Return(events);
     var repository = new DomainRepository(fakeEventStore);
     var aggregateRoot = repository.Get<EmptyDomainObject>(id);
 }
예제 #7
0
        public void ShouldThrowExceptionWhenNoDomainEventExistForAnAggregate()
        {
            var id             = Guid.NewGuid();
            var events         = new List <DomainEvent>();
            var fakeEventStore = MockRepository.GenerateMock <IEventStore>();

            fakeEventStore.Stub(x => x.GetEventsForAggregate <EmptyDomainObject>(id)).Return(events);
            var repository    = new DomainRepository(fakeEventStore);
            var aggregateRoot = repository.Get <EmptyDomainObject>(id);
        }
예제 #8
0
        public void TestGetActiveItemAfterUnDelete()
        {
            ItemSetUp();

            With.Transaction(delegate
            {
                DomainRepository <T> .UnDelete(ActiveDeletedItem);
            });

            Assert.IsNotNull(DomainRepository <T> .GetActive(ActiveDeletedItem.ObjectId));
            Assert.IsNotNull(DomainRepository <T> .Get(ActiveDeletedItem.ObjectId));
        }
예제 #9
0
        public void TestGetItem()
        {
            ItemSetUp();

            Assert.IsNotNull(DomainRepository <T> .Get(ActiveItem.ObjectId));
            Assert.IsNotNull(DomainRepository <T> .Get(ArchivedItem.ObjectId));

            Assert.IsNull(DomainRepository <T> .Get(ActiveDeletedItem.ObjectId));
            Assert.IsNull(DomainRepository <T> .Get(ArchivedDeletedItem.ObjectId));
            Assert.IsNull(DomainRepository <T> .Get(DraftDeletedItem.ObjectId));
            Assert.IsNull(DomainRepository <T> .Get(DraftItem.ObjectId));
        }
 public void ShouldGetAggregateRootById()
 {
     var id = Guid.NewGuid();
     var events = new List<DomainEvent>
         {
             new EmptyDomainEvent(id)
                 {
                     Version = 1
                 }
         };
     var fakeEventStore = MockRepository.GenerateMock<IEventStore>();
     fakeEventStore.Stub(x => x.GetEventsForAggregate<EmptyDomainObject>(id)).Return(events);
     var repository = new DomainRepository(fakeEventStore);
     var aggregateRoot = repository.Get<EmptyDomainObject>(id);
     Assert.That(aggregateRoot.Version, Is.EqualTo(1));
 }
예제 #11
0
        public void ShouldGetAggregateRootById()
        {
            var id     = Guid.NewGuid();
            var events = new List <DomainEvent>
            {
                new EmptyDomainEvent(id)
                {
                    Version = 1
                }
            };
            var fakeEventStore = MockRepository.GenerateMock <IEventStore>();

            fakeEventStore.Stub(x => x.GetEventsForAggregate <EmptyDomainObject>(id)).Return(events);
            var repository    = new DomainRepository(fakeEventStore);
            var aggregateRoot = repository.Get <EmptyDomainObject>(id);

            Assert.That(aggregateRoot.Version, Is.EqualTo(1));
        }