public void TestInitilize()
        {
            _contextHelpRefData = new List <ContextHelpRefData>
            {
                new ContextHelpRefData
                {
                    Id       = 1,
                    HelpText = "This is help for the <b>Home Page</b>.",
                    Key      = "homepage",
                    Title    = "Home Page Help",
                },
            };

            _mockContextHelpRefDataRepository = MockRepositoryHelper.Create(_contextHelpRefData);

            _unitOfWork = new Mock <IUnitOfWork>();


            _contextHelpRefDataService = new ContextHelpRefDataService(_mockContextHelpRefDataRepository.Object,
                                                                       _unitOfWork.Object);

            Bootstrapper.SetupAutoMapper();
        }
Beispiel #2
0
        public HelpController(IContextHelpRefDataService contextHelpRefDataService,
                              IRepository <Asset> assetRepository,
                              IContextManager contextManager)
        {
            if (contextHelpRefDataService == null)
            {
                throw new ArgumentNullException(nameof(contextHelpRefDataService));
            }

            if (assetRepository == null)
            {
                throw new ArgumentNullException(nameof(assetRepository));
            }

            if (contextManager == null)
            {
                throw new ArgumentNullException(nameof(contextManager));
            }

            _contextHelpRefDataService = contextHelpRefDataService;
            _assetRepository           = assetRepository;
            _contextManager            = contextManager;
        }
        public void Initialize()
        {
            var container = new ObjectBuilder(ObjectBuilderHelper.SetupObjectBuilder).GetContainer();

            Logger.SetLogWriter(new LogWriterFactory().Create(), false);

            var config  = ConfigurationSourceFactory.Create();
            var factory = new ExceptionPolicyFactory(config);

            var exceptionManager = factory.CreateManager();

            container.RegisterInstance(exceptionManager);

            ExceptionPolicy.SetExceptionManager(exceptionManager, false);

            _mockUnitOfWork = new Mock <IUnitOfWork>();

            _appContext = new AppContext();

            _mockAppUserContext = new Mock <IAppUserContext>();
            _mockAppUserContext.Setup(s => s.Current).Returns(_appContext);


            _mockContextManager  = new Mock <IContextManager>();
            _mockResponseManager = new Mock <IResponseManager>();
            _mockContextManager.Setup(s => s.ResponseManager).Returns(_mockResponseManager.Object);

            _contextHelpRefData = new List <ContextHelpRefData>
            {
                new ContextHelpRefData
                {
                    Id       = 1,
                    Key      = "homepage",
                    Title    = "Homepage",
                    HelpText = "This is the <b>Home Page</b> help.",
                    AssetId  = 1,
                    Asset    = new Asset {
                        Id               = 1,
                        FileExtension    = ".mp4",
                        FileName         = Guid.NewGuid().ToString(),
                        OriginalFileName = "Register SLM Generator Tutorial",
                        MimeType         = "video/mp4",
                        FullPath         = "Fujitsu.SLM.Web.Tests\\Register SLM Generator Tutorial.mp4"
                    }
                },
                new ContextHelpRefData
                {
                    Id       = 2,
                    Key      = "changepasswordpage",
                    Title    = "ChangePasswordPage",
                    HelpText = "This is the <b>Change Password</b> help.",
                    AssetId  = 2,
                    Asset    = new Asset {
                        Id               = 2,
                        FileExtension    = ".mp4",
                        FileName         = Guid.NewGuid().ToString(),
                        OriginalFileName = "ChangePassword",
                        MimeType         = "video/mp4",
                        FullPath         = "C:\\Media\\Video\\ChangePassword.mp4"
                    }
                }
            };

            _mockContextHelpRefDataRepository = MockRepositoryHelper.Create(_contextHelpRefData, (entity, id) => entity.Id == (int)id);

            _mockContextHelpRefDataService = new Mock <IContextHelpRefDataService>();
            _mockContextHelpRefDataService.Setup(s => s.GetByHelpKey("homepage")).Returns(_contextHelpRefData[0]);
            _mockContextHelpRefDataService.Setup(s => s.GetById(It.IsAny <int>()))
            .Returns <int>(id => _contextHelpRefData.SingleOrDefault(x => x.Id == id));

            _mockAssetRepository = new Mock <IRepository <Asset> >();

            _mockController = new HelpController(
                _mockContextHelpRefDataService.Object,
                _mockAssetRepository.Object,
                _mockContextManager.Object
                );

            _contextHelpRefDataService = new ContextHelpRefDataService(_mockContextHelpRefDataRepository.Object,
                                                                       _mockUnitOfWork.Object);

            _controller = new HelpController(
                _contextHelpRefDataService,
                _mockAssetRepository.Object,
                _mockContextManager.Object
                );

            Bootstrapper.SetupAutoMapper();
        }