예제 #1
0
        public void SaveComplexData()
        {
            MonCFExampleDataStore dataStore = new MonCFExampleDataStore("mongodb://localhost");

            Guid theID = Guid.NewGuid();

            var complexData = TestUtils.GetRandomComplexData();
            complexData.Id = theID;

            dataStore.SaveComplexData(complexData);

            var dataBack = dataStore.GetComplexData(theID);

            Assert.Equal(complexData, dataBack);
        }
예제 #2
0
파일: Program.cs 프로젝트: orthros/MonCF
        static void Main(string[] args)
        {
            ///TODO: MEF out or make in the App.config the connection string for Mongo
            IMonCFDataStore moncfDS = new MonCFExampleDataStore("mongodb://localhost");
            IContractExtensionFactory factory = new ContractExtensionFactory();

            Func<SimpleService> factoryConstructor = () => new SimpleService(moncfDS);

            using (ServiceHost sh = new InjectionServiceHost<SimpleService>(factoryConstructor, typeof(SimpleService)))
            {
                #region Apply extensions
                try
                {
                    foreach (var endpoint in sh.Description.Endpoints)
                    {
                        factory.ApplyContractExtensions(endpoint);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error("Hit an error applying the extensions to the endpoint");
                    Logger.Fatal(e.Message);
                }
                #endregion                

                #region Run
                try
                {
                    sh.Open();

                    Logger.Info("Services are running\nPress 'Enter' to stop them.");
                    Console.ReadLine();

                    sh.Close();
                }
                catch (TimeoutException timeProblem)
                {
                    Logger.Fatal(timeProblem.Message);
                    Console.ReadLine();
                }
                catch (CommunicationException commProblem)
                {
                    Logger.Fatal(commProblem.Message);
                    Console.ReadLine();
                }
                #endregion
            }
        }
예제 #3
0
        public void SaveComplexSet()
        {
            MonCFExampleDataStore dataStore = new MonCFExampleDataStore("mongodb://localhost");

            List<ComplexData> cds = new List<ComplexData>();

            for (int i = 0; i < 100; i++)
            {
                var complexData = TestUtils.GetRandomComplexData();

                cds.Add(complexData);
            }

            dataStore.SaveComplexDataSet(cds);

            foreach (var cd in cds)
            {
                var retcd = dataStore.GetComplexData(cd.Id);

                Assert.Equal(cd, retcd);
            }
        }