Exemple #1
0
        public void InitEmeddedDocumentStore(string dataDirectory, IDocumentQueryListener queryListener)
        {
            var mockRavenDBConfigurationInstance = MockRepository.GenerateStub <RavenDBConfiguration>();

            Func <IDocumentStore> setDocumentStore =
                () =>
            {
                var documentStore = new EmbeddableDocumentStore
                {
                    DataDirectory = dataDirectory
                };
                if (queryListener != null)
                {
                    documentStore.RegisterListener(queryListener);
                }

                return(documentStore);
            };


            mockRavenDBConfigurationInstance.Stub(x => x.GetDocumentStore()).Do(setDocumentStore);
            RavenDBConfiguration.Instance(mockRavenDBConfigurationInstance).Init();

            //RavenDBConfiguration.Instance().CreateIndex(typeof (Package_CurrentInventory).Assembly);
        }
Exemple #2
0
        public void InitEmeddedInMemoryDocumentStore()
        {
            var mockRavenDBConfigurationInstance = MockRepository.GenerateStub <RavenDBConfiguration>();

            Func <IDocumentStore> setDocumentStore =
                () =>
            {
                var documentStore = new EmbeddableDocumentStore
                {
                    RunInMemory = true
                };
                return(documentStore);
            };


            mockRavenDBConfigurationInstance.Stub(x => x.GetDocumentStore()).Do(setDocumentStore);
            RavenDBConfiguration.Instance(mockRavenDBConfigurationInstance).Init();
            //if you don't want to use the embedded version then comment out the line above and uncomment out the
            //line below
            //RavenDBConfiguration.Instance().Init();


            RavenDBConfiguration.Instance().CreateIndex(typeof(Package_CurrentInventory).Assembly);
        }
        public void LoadDoesNotRoundtripOnIncludedCustomer()
        {
            var newSession = RavenDBConfiguration.Instance().OpenNewSession();

            var customer1 = new Customer
            {
                FirstName = "Test1",
                LastName  = "User",
                Phones    =
                    new List <CustomerPhone> {
                    new CustomerPhone {
                        Number = "11111111", PhoneType = PhoneTypes.WorkPhone1
                    }
                }
            };

            newSession.Store(customer1);

            var customer2 = new Customer
            {
                FirstName = "Test2",
                LastName  = "User",
                Phones    =
                    new List <CustomerPhone> {
                    new CustomerPhone {
                        Number = "22222222", PhoneType = PhoneTypes.WorkPhone1
                    }
                }
            };

            newSession.Store(customer2);

            var unitResident = new UnitResident
            {
                CommunityCode    = "101",
                SubCommunityCode = "101",
                BuildingId       = "01",
                UnitId           = "0420",
                UnitAddress      = "4501 Connecticut Ave NW #420",
                LastName         = "",
                FirstName        = ""
            };

            var package1 = new Package
            {
                UnitResident  = unitResident,
                CommunityCode = "101",
                CustomerIds   = new List <string> {
                    customer1.Id, customer2.Id
                },
                PackageType = "FedEx",
                Status      = PackageStatusCodes.Received.ToString()
            };

            newSession.Store(package1);
            newSession.SaveChanges();


            var service        = new NotificationService();
            var currentSession = AbstractRavenService.GetCurrentDocumentSession();

            var packages = service.GetPackageInventory("101", string.Empty, false, false, null, null, 10);

            Assert.AreEqual(1, currentSession.Advanced.NumberOfRequests);

            Assert.IsNotNull(packages);
            foreach (var package in packages)
            {
                Assert.IsTrue(package.Customers.Count > 0);
            }
        }
 public void Setup()
 {
     CreateHttpContext();
     RavenDBConfiguration.Instance().Init();
 }