Пример #1
0
        public void GetAll_will_return_debug_info_ordered_by_created_date_latest_info_first()
        {
            //arrange
            var debug1 = new DebugInfo()
            {
                Type = "All", DateCreated = new DateTime(2010, 10, 1)
            };
            var debug2 = new DebugInfo()
            {
                Type = "All", DateCreated = new DateTime(2012, 10, 1)
            };

            _debugInfoRepository.Add(debug1);
            _debugInfoRepository.Add(debug2);

            var mut = new DebugInfoService(_debugInfoRepository);
            //act
            var result = mut.GetAll().ToList();

            //assert
            Assert.AreEqual(new DateTime(2012, 10, 1), result[0].DateCreated);
            //cleanup
            _debugInfoRepository.Delete(debug1);
            _debugInfoRepository.Delete(debug2);
        }
Пример #2
0
        public void Get_when_enum_type_is_all_returns_all_debug_info_not_developer()
        {
            //arrange
            var debug1 = new DebugInfo()
            {
                Type = "Developer"
            };
            var debug2 = new DebugInfo()
            {
                Type = "All"
            };

            _debugInfoRepository.Add(debug1);
            _debugInfoRepository.Add(debug2);

            var mut = new DebugInfoService(_debugInfoRepository);
            //act
            var result = mut.Get(DebugInfoTypeEnum.All).ToList();

            //assert
            Assert.AreNotEqual("Developer", result[0].Type);
            //cleanup
            _debugInfoRepository.Delete(debug1);
            _debugInfoRepository.Delete(debug2);
        }
Пример #3
0
        public void Get_when_enum_type_is_Error_returns_debug_info_ordered_by_created_date_latest_info_first()
        {
            //arrange
            var debug1 = new DebugInfo()
            {
                Type = "Error", DateCreated = new DateTime(2010, 10, 1)
            };
            var debug2 = new DebugInfo()
            {
                Type = "Error", DateCreated = new DateTime(2012, 10, 1)
            };


            _debugInfoRepository.Add(debug1);
            _debugInfoRepository.Add(debug2);

            var mut = new DebugInfoService(_debugInfoRepository);
            //act
            var result = mut.Get(DebugInfoTypeEnum.Error).ToList();

            //assert
            Assert.AreEqual(new DateTime(2012, 10, 1), result[0].DateCreated);
            //cleanup
            _debugInfoRepository.Delete(debug1);
            _debugInfoRepository.Delete(debug2);
        }
Пример #4
0
        public void GetAll_will_return_all_type_which_is_not_developer()
        {
            //arrange
            var debug1 = new DebugInfo()
            {
                Type = "Developer"
            };
            var debug2 = new DebugInfo()
            {
                Type = "All"
            };

            _debugInfoRepository.Add(debug1);
            _debugInfoRepository.Add(debug2);

            var mut = new DebugInfoService(_debugInfoRepository);
            //act
            var result = mut.GetAll().ToList();

            //assert
            Assert.AreNotEqual("Developer", result[0].Type);
            //cleanup
            _debugInfoRepository.Delete(debug1);
            _debugInfoRepository.Delete(debug2);
        }
Пример #5
0
        public void Get_when_enum_type_is_Error_returns_debug_info_selected_to_check()
        {
            //arrange
            var debug1 = new DebugInfo()
            {
                Type = "Error"
            };
            var debug2 = new DebugInfo()
            {
                Type = "All"
            };

            _debugInfoRepository.Add(debug1);
            _debugInfoRepository.Add(debug2);

            var mut = new DebugInfoService(_debugInfoRepository);
            //act
            var result = mut.Get(DebugInfoTypeEnum.Error).ToList();

            //assert
            Assert.AreEqual("Error", result[0].Type);
            //cleanup
            _debugInfoRepository.Delete(debug1);
            _debugInfoRepository.Delete(debug2);
        }
Пример #6
0
        public void Add_will_set_info_updated_by_to_empty_string()
        {
            //arrange
            var debug1 = new DebugInfo()
            {
                Id = 1, UpdatedBy = "test-to-be-set-to-empty"
            };
            var mut = new DebugInfoService(_debugInfoRepository);

            //act
            mut.Add(debug1);
            var result = _debugInfoRepository.GetQuery().First(x => x.Id == 1);

            //assert
            Assert.AreEqual("", result.UpdatedBy);
            //cleanup
            _debugInfoRepository.Delete(debug1);
        }
Пример #7
0
        private static void InitialiseDatabase()
        {
            // Setup StructureMap to determine the concrete repository pattern to use.
            ObjectFactory.Initialize(
                x =>
            {
                x.For <IUnitOfWorkFactory>().Use <EFUnitOfWorkFactory>();
                x.For(typeof(IRepository <>)).Use(typeof(Repository <>));
                x.For <ISqlTableUtility>().Use <SqlTableUtility>();
                x.For <IDataSetSchemaDefinitionService>().Use <DataSetSchemaDefinitionService>();
                x.For <IDataSetDetailSqlRepo>().Use <DataSetDetailSqlRepo>();
                x.For <ISystemConfigurationService>().Use <SystemConfigurationService>();
                x.For <ICacheProvider>().Use <HttpCache>();
                x.For <IDataSetDetailCsvProcessor>().Use <DataSetDetailCsvProcessor>();
                x.For <IDataSetSchemaService>().Use <DataSetSchemaService>();
            }
                );


            // Select an Entity Framework model to use with the factory.
            EFUnitOfWorkFactory.SetObjectContext(() => new DataShareContext());

            //Never recreate the database
            Database.SetInitializer <DataShareContext>(null);



            //initialise all services
            _dataSetSchemaService = new DataSetSchemaService(
                ObjectFactory.GetInstance <IRepository <DataSetSchema> >()
                , ObjectFactory.GetInstance <DataSetSchemaDefinitionService>()
                , ObjectFactory.GetInstance <IRepository <DataSetDetail> >()
                , ObjectFactory.GetInstance <ISqlTableUtility>());

            _uploaderService = new DataSetDetailUploaderService(
                _dataSetSchemaService
                , ObjectFactory.GetInstance <IRepository <DataSetDetail> >()
                , ObjectFactory.GetInstance <IDataSetDetailCsvProcessor>()
                , ObjectFactory.GetInstance <IDataSetDetailSqlRepo>());

            _debugInfoService = new DebugInfoService(ObjectFactory.GetInstance <IRepository <DebugInfo> >());
        }