protected override void AdditionalSetup()
        {
            _mockUserInteraction = new Mock <ICustomUserInteraction>();
            Ioc.RegisterSingleton <ICustomUserInteraction>(_mockUserInteraction.Object);

            _mockMessenger = new Mock <IMvxMessenger>();
            Ioc.RegisterSingleton <IMvxMessenger>(_mockMessenger.Object);

            _fixture = new Fixture().Customize(new AutoMoqCustomization());
            _fixture.OmitProperty("EffectiveDateString");
            _fixture.Customize <InstructionSafetyCheckViewModel>(vm => vm.Without(x => x.SafetyCheckItemViewModels));
            _fixture.Customize <InstructionSafetyCheckViewModel>(vm => vm.Without(x => x.SafetyProfileVehicle));
            _fixture.Customize <SafetyCheckFault>(vm => vm.With(x => x.Status, Core.Enums.SafetyCheckStatus.Passed));

            _driver  = _fixture.Create <Core.Models.Driver>();
            _vehicle = _fixture.Create <Core.Models.Vehicle>();
            _trailer = _fixture.Create <Core.Models.Trailer>();

            _infoService = _fixture.Create <InfoService>();
            _fixture.Inject <IInfoService>(_infoService);
            _infoService.SetCurrentDriver(_driver);
            _infoService.SetCurrentVehicle(_vehicle);

            _safetyCheckService = _fixture.Create <SafetyCheckService>();
            _fixture.Inject <ISafetyCheckService>(_safetyCheckService);

            _mobileData = _fixture.SetUpInstruction(Core.Enums.InstructionType.Collect, false, true, false, false, false, false, true, null);
            _navData    = new NavData <MobileData>()
            {
                Data = _mobileData
            };

            _navData.OtherData["UpdatedTrailer"] = _trailer;

            _safetyCheckService.CurrentVehicleSafetyCheckData   = _vehicleSafetyCheckData = _fixture.Create <SafetyCheckData>();
            _navData.OtherData["UpdatedTrailerSafetyCheckData"] = _trailerSafetyCheckData = _fixture.Create <SafetyCheckData>();

            var mockMobileDataRepo = _fixture.InjectNewMock <IMobileDataRepository>();

            mockMobileDataRepo.Setup(mdr => mdr.GetByIDAsync(It.Is <Guid>(i => i == _mobileData.ID))).ReturnsAsync(_mobileData);

            _mockSafetyProfileRepository = _fixture.InjectNewMock <ISafetyProfileRepository>();
            _mockConfigRepository        = _fixture.InjectNewMock <IConfigRepository>();
            _mockVehicleRepo             = _fixture.InjectNewMock <IVehicleRepository>();

            _mockVehicleRepo.Setup(vr => vr.GetByIDAsync(_vehicle.ID)).ReturnsAsync(_vehicle);

            var repositories = _fixture.Create <Repositories>();

            _fixture.Inject <IRepositories>(repositories);

            _mockNavigationService = _fixture.InjectNewMock <INavigationService>();
            Ioc.RegisterSingleton <INavigationService>(_mockNavigationService.Object);

            _safetyProfiles = CreateSafetyProfiles();
        }
Ejemplo n.º 2
0
        protected override void AdditionalSetup()
        {
            var mockDispatcher = new MockDispatcher();

            Ioc.RegisterSingleton <IMvxViewDispatcher>(mockDispatcher);
            Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(mockDispatcher);

            var mockUserInteraction = new Mock <ICustomUserInteraction>();

            Ioc.RegisterSingleton <ICustomUserInteraction>(mockUserInteraction.Object);

            _mockUserInteraction = new Mock <ICustomUserInteraction>();
            _mockUserInteraction.Setup(ui => ui.ConfirmAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(true);
            Ioc.RegisterSingleton <ICustomUserInteraction>(_mockUserInteraction.Object);

            _fixture = new Fixture().Customize(new AutoMoqCustomization());

            _fixture.Register <IReachability>(() => Mock.Of <IReachability>(r => r.IsConnected() == true));

            _trailer = new Core.Models.Trailer()
            {
                Registration = "TestRegistration", ID = Guid.NewGuid()
            };
            _trailerItemViewModel = new TrailerItemViewModel()
            {
                Trailer = _trailer
            };

            _infoService = _fixture.Create <InfoService>();
            _fixture.Inject <IInfoService>(_infoService);

            _mockMessenger = Ioc.RegisterNewMock <IMvxMessenger>();
            _mockMessenger.Setup(m => m.Unsubscribe <GatewayInstructionNotificationMessage>(It.IsAny <MvxSubscriptionToken>()));
            _mockMessenger.Setup(m => m.Subscribe(It.IsAny <Action <GatewayInstructionNotificationMessage> >(), It.IsAny <MvxReference>(), It.IsAny <string>())).Returns(_fixture.Create <MvxSubscriptionToken>());

            _navigationServiceMock = _fixture.InjectNewMock <INavigationService>();
            Ioc.RegisterSingleton <INavigationService>(_navigationServiceMock.Object);

            var repositories = _fixture.Create <IRepositories>();

            _fixture.Inject(repositories);
            _mockRepositories = Mock.Get(repositories);
            Ioc.RegisterSingleton <IRepositories>(_mockRepositories.Object);

            var applicationRepository = Mock.Of <IApplicationProfileRepository>(apr => apr.GetAllAsync() == Task.FromResult(_fixture.CreateMany <Core.Models.ApplicationProfile>()));

            _mockRepositories.Setup(r => r.ApplicationRepository).Returns(applicationRepository);
        }