protected override void InitialiseMocks()
 {
     AddMock <IEstablishmentReadService>();
     AddMock <IGroupReadService>();
     AddMock <IGroupsWriteService>();
     AddMock <ICachedLookupService>();
     AddMock <ICompaniesHouseService>();
     AddMock <ISecurityService>();
     RealObjects.Add(new NomenclatureService());
     base.InitialiseMocks();
 }
 public void LogErrorAndWarnings(IActivityMonitor monitor)
 {
     Throw.CheckNotNullArgument(monitor);
     using (monitor.OpenTrace($"Collector summary:"))
     {
         if (PocoSupport == null)
         {
             monitor.Fatal($"Poco support failed!");
         }
         RealObjects.LogErrorAndWarnings(monitor);
         AutoServices.LogErrorAndWarnings(monitor);
     }
 }
Exemplo n.º 3
0
        protected void SetupObjectUnderTest()
        {
            if (typeof(T).IsAssignableTo <Controller>())
            {
                SetupHttpRequest();
            }

            var containerBuilder = new ContainerBuilder();

            //containerBuilder.RegisterModule<ValidationModule>();
            containerBuilder.RegisterType <T>().AsImplementedInterfaces().AsSelf();

            foreach (var mock in mocks)
            {
                containerBuilder.RegisterInstance(mock.Value.Object).AsImplementedInterfaces().AsSelf();
                if (!mock.Key.IsInterface)
                {
                    containerBuilder.RegisterInstance(mock.Value.Object).As(mock.Key);
                }
            }

            RealObjects.ForEach(x => containerBuilder.RegisterInstance(x).AsImplementedInterfaces().AsSelf());

            var container = containerBuilder.Build();

            containerLifetime = container.BeginLifetimeScope();
            ObjectUnderTest   = containerLifetime.Resolve <T>();

            var controller = ObjectUnderTest as Controller;

            if (controller != null)
            {
                controller.ControllerContext = GetMock <ControllerContext>().Object;
                GetMock <ControllerContext>().SetupGet(c => c.Controller).Returns(controller);
                controller.Url = GetMock <UrlHelper>().Object;
            }
        }