protected override MockingKernel CreateMockingKernel() { var kernel = new NSubstituteMockingKernel(); kernel.Load(new EntityFrameworkTestingNSubstituteModule()); return(kernel); }
public void ScanningOurselvesShouldReturnResults() { var repoRootPath = CoreUtility.FindRepositoryRoot(IntegrationTestHelper.GetIntegrationTestRootDirectory()); var router = new RoutingState(); var kernel = new NSubstituteMockingKernel(); var fixture = setupStandardFixture(router, kernel, () => kernel.Bind <IRepoAnalysisProvider>().To <RepoAnalysisProvider>()); fixture.AnalyzeRepo.Execute(repoRootPath); fixture.AnalyzeRepo.ItemsInflight.Where(x => x == 0).First(); fixture.BranchInformation.ShouldNotBeNull(); fixture.CurrentRepoPath.ShouldEqual(repoRootPath); this.Log().Info(JsonConvert.SerializeObject(fixture.BranchInformation, Formatting.Indented)); // We should have both the WD and the branches fixture.BranchInformation.Any(x => x.BranchName.ToLowerInvariant().Contains("working")).ShouldBeTrue(); fixture.BranchInformation.Any(x => x.BranchName.ToLowerInvariant().Contains("master")).ShouldBeTrue(); // We should have examined some files fixture.BranchInformation.All(x => x.BadEncodingInfoHeader != null).ShouldBeTrue(); fixture.BranchInformation.All(x => x.BadEndingsInfoHeader != null).ShouldBeTrue(); fixture.BranchInformation.All(x => x.Model.TotalFilesExamined > 0).ShouldBeTrue(); // .gitignored files shouldn't show up var working = fixture.BranchInformation.First(x => x.BranchName == Constants.WorkingDirectory); working.Model.BadLineEndingFiles.Any(x => x.Key.ToLowerInvariant().Contains("_resharper")).ShouldBeFalse(); }
public void AppStateShouldBeSetOnRepairClicked() { var router = new RoutingState(); var kernel = new NSubstituteMockingKernel(); IRoutableViewModel latestVm = null; var fixture = setupStandardFixture(router, kernel, () => { var branchInfo = new Dictionary <string, HeuristicTreeInformation>() { { "Working Directory", new HeuristicTreeInformation("derp", true) } }; kernel.Get <IRepoAnalysisProvider>().AnalyzeRepo(null) .ReturnsForAnyArgs(Observable.Return(Tuple.Create("foo", branchInfo))); router.ViewModelObservable().Subscribe(x => latestVm = x); }); fixture.AnalyzeRepo.Execute("foo"); fixture.RepairButtonVisibility.ShouldEqual(Visibility.Visible); fixture.RepairButton.Execute(null); var result = kernel.Get <IAppState>(); (latestVm is IRepairViewModel).ShouldBeTrue(); result.CurrentRepo.ShouldEqual("foo"); result.BranchInformation.ShouldNotBeNull(); }
public void RealObjectsAreCreatedForAutoBindableTypes() { using (var kernel = new NSubstituteMockingKernel()) { var instance = kernel.Get <DummyClass>(); instance.Should().NotBeNull(); } }
public void MocksAreSingletons() { using (var kernel = new NSubstituteMockingKernel()) { var firstReference = kernel.Get <IDummyService>(); var secondReference = kernel.Get <IDummyService>(); firstReference.Should().BeSameAs(secondReference); } }
public void TheInjectedDependenciesAreMocks() { using (var kernel = new NSubstituteMockingKernel()) { var instance = kernel.Get <DummyClass>(); instance.DummyService.Do(); instance.DummyService.Received().Do(); } }
public void RealObjectsAreSingletons() { using (var kernel = new NSubstituteMockingKernel()) { var instance1 = kernel.Get <DummyClass>(); var instance2 = kernel.Get <DummyClass>(); instance1.Should().BeSameAs(instance2); } }
public void SetUpKernel() { var settings = new NinjectSettings { AllowNullInjection = true }; kernel = new NSubstituteMockingKernel(settings); }
public void SetUp() { _fixture.Behaviors.Add(new OmitOnRecursionBehavior()); IMapper mapper = new MapperConfiguration(cfg => cfg.AddProfile <AutoMapping>()).CreateMapper();; using (var kernel = new NSubstituteMockingKernel()) { _expositionService = kernel.Get <IExpositionService>(); } _unitOfWork = Substitute.For <IUnitOfWork>(); _excursionsScheduleService = new ExcursionsScheduleService(_expositionService, mapper, _unitOfWork); }
public void AnalyzeRepoWithThingsThatArentReposShouldFail(string input) { var router = new RoutingState(); var kernel = new NSubstituteMockingKernel(); UserError error = null; var fixture = setupStandardFixture(router, kernel, () => kernel.Bind <IRepoAnalysisProvider>().To <RepoAnalysisProvider>()); using (UserError.OverrideHandlersForTesting(x => { error = x; return(RecoveryOptionResult.CancelOperation); })) { fixture.AnalyzeRepo.Execute(input); } error.ShouldNotBeNull(); fixture.RepairButtonVisibility.ShouldNotEqual(Visibility.Visible); }
public void Test() { // Arrange using var kernel = new NSubstituteMockingKernel(); kernel.Get <INameProvider>().GetName().Returns("A Name"); // Act var sut = kernel.Get <MyClassAuto>(); sut.DoGreeting(); // Assert kernel.Get <IGreetingService>().Received().Greet("A Name"); }
protected override MockingKernel CreateMockingKernel() { var kernel = new NSubstituteMockingKernel(); kernel.Load(new EntityFrameworkTestingNSubstituteModule()); return kernel; }
internal SetSubstituteSyntax(NSubstituteMockingKernel kernel) { this.kernel = kernel; }
public UsersManagementTests() { this.IoCKernel = new NSubstituteMockingKernel(); this.IoCKernel.Bind <Core.Kernel>().ToMock(); }
internal SetSubstituteBuilder(NSubstituteMockingKernel kernel) { this.kernel = kernel; }
protected TesteBase() { kernel = new NSubstituteMockingKernel(); }