public void Setup() { _metrics = new Moq.Mock <IMetrics>(); _snapshots = new Moq.Mock <IStoreSnapshots>(); _eventstore = new Moq.Mock <IStoreEvents>(); _oobStore = new Moq.Mock <IOobWriter>(); _factory = new Moq.Mock <IEventFactory>(); _uow = new Moq.Mock <IDomainUnitOfWork>(); _event = new Moq.Mock <IFullEvent>(); _mapper = new Moq.Mock <IEventMapper>(); _mapper.Setup(x => x.GetMappedTypeFor(typeof(FakeEvent))).Returns(typeof(FakeEvent)); _resolver = new FakeResolver(); var fake = new FakeConfiguration(); fake.FakeContainer.Setup(x => x.Resolve <IEventMapper>()).Returns(_mapper.Object); fake.FakeContainer.Setup(x => x.Resolve <IMetrics>()).Returns(_metrics.Object); fake.FakeContainer.Setup(x => x.Resolve(typeof(FakeResolver))).Returns(_resolver); fake.FakeContainer.Setup(x => x.Resolve <IStoreSnapshots>()).Returns(_snapshots.Object); fake.FakeContainer.Setup(x => x.Resolve <IStoreEvents>()).Returns(_eventstore.Object); Configuration.Settings = fake; _snapshots.Setup(x => x.GetSnapshot <FakeEntity>(Moq.It.IsAny <string>(), Moq.It.IsAny <Id>(), Moq.It.IsAny <Id[]>())) .Returns(Task.FromResult((ISnapshot)null)); _event.Setup(x => x.Event).Returns(new FakeEvent()); _repository = new Aggregates.Internal.Repository <FakeEntity, FakeState>(_metrics.Object, _eventstore.Object, _snapshots.Object, _oobStore.Object, _factory.Object, _uow.Object); }
public void SetUp() { _testModule = TestData.DogeCoinFlag_101_module(); _instance = new DisposableKSP(); _nullUser = new NullUser(); _config = new FakeConfiguration(_instance.KSP, _instance.KSP.Name); _manager = new KSPManager(_nullUser, _config); _registryManager = CKAN.RegistryManager.Instance(_instance.KSP); _registry = _registryManager.registry; _installer = CKAN.ModuleInstaller.GetInstance(_instance.KSP, _manager.Cache, _nullUser); _gameDir = _instance.KSP.GameDir(); _gameDataDir = _instance.KSP.GameData(); _registry.AddAvailable(_testModule); var testModFile = TestData.DogeCoinFlagZip(); _manager.Cache.Store(_testModule, testModFile); HashSet <string> possibleConfigOnlyDirs = null; _installer.InstallList( new List <string>() { _testModule.identifier }, new RelationshipResolverOptions(), _registryManager, ref possibleConfigOnlyDirs ); }
[Test] //37a33 public void Ctor_InvalidAutoStart_DoesNotThrow() { var config = new FakeConfiguration(tidy.KSP, "invalid"); Assert.DoesNotThrow(() => new GameInstanceManager(new NullUser(), config)); config.Dispose(); }
public void UninstallModNotFound() { using (var tidy = new DisposableKSP()) { var config = new FakeConfiguration(tidy.KSP, tidy.KSP.Name); GameInstanceManager manager = new GameInstanceManager( new NullUser(), config ) { CurrentInstance = tidy.KSP }; Assert.Throws <ModNotInstalledKraken>(delegate { HashSet <string> possibleConfigOnlyDirs = null; // This should throw, as our tidy KSP has no mods installed. new CKAN.ModuleInstaller(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(new List <string> { "Foo" }, ref possibleConfigOnlyDirs, CKAN.RegistryManager.Instance(manager.CurrentInstance)); }); manager.CurrentInstance = null; // I weep even more. manager.Dispose(); config.Dispose(); } }
public void Setup() { _metrics = new Moq.Mock <IMetrics>(); _context = new Moq.Mock <IIncomingLogicalMessageContext>(); _next = new Moq.Mock <Func <Task> >(); _contextBag = new ContextBag(); var fake = new FakeConfiguration(); Configuration.Settings = fake; _metrics.Setup(x => x.Begin(Moq.It.IsAny <string>())).Returns(new Moq.Mock <ITimer>().Object); _context.Setup(x => x.Extensions).Returns(_contextBag); _context.Setup(x => x.MessageHeaders).Returns(new Dictionary <string, string> { [Headers.MessageIntent] = MessageIntentEnum.Send.ToString() }); _context.Setup(x => x.Headers).Returns(new Dictionary <string, string> { [Headers.MessageIntent] = MessageIntentEnum.Send.ToString() }); _context.Setup(x => x.Message).Returns(new LogicalMessage(new global::NServiceBus.Unicast.Messages.MessageMetadata(typeof(Messages.ICommand)), 1)); _executor = new Internal.LocalMessageUnpack(_metrics.Object); }
public void ConstructModList_NumberOfRows_IsEqualToNumberOfMods() { using (var tidy = new DisposableKSP()) { var config = new FakeConfiguration(tidy.KSP, tidy.KSP.Name); GameInstanceManager manager = new GameInstanceManager( new NullUser(), config ) { CurrentInstance = tidy.KSP }; var registry = Registry.Empty(); registry.AddAvailable(TestData.FireSpitterModule()); registry.AddAvailable(TestData.kOS_014_module()); var main_mod_list = new ModList(null); var mod_list = main_mod_list.ConstructModList( new List <GUIMod> { new GUIMod(TestData.FireSpitterModule(), registry, manager.CurrentInstance.VersionCriteria()), new GUIMod(TestData.kOS_014_module(), registry, manager.CurrentInstance.VersionCriteria()) }, manager.CurrentInstance.Name ); Assert.That(mod_list, Has.Count.EqualTo(2)); manager.Dispose(); config.Dispose(); } }
public void Setup() { _metrics = new Moq.Mock <IMetrics>(); _context = new Moq.Mock <IIncomingLogicalMessageContext>(); _domainUow = new Moq.Mock <IDomainUnitOfWork>(); _uow = new Moq.Mock <IUnitOfWork>(); _channel = new Moq.Mock <IDelayedChannel>(); _next = new Moq.Mock <Func <Task> >(); _contextBag = new ContextBag(); var fake = new FakeConfiguration(); fake.FakeContainer.Setup(x => x.Resolve <IDomainUnitOfWork>()).Returns(_domainUow.Object); fake.FakeContainer.Setup(x => x.Resolve <IUnitOfWork>()).Returns(_uow.Object); fake.FakeContainer.Setup(x => x.Resolve <IDelayedChannel>()).Returns(_channel.Object); Configuration.Settings = fake; _metrics.Setup(x => x.Begin(Moq.It.IsAny <string>())).Returns(new Moq.Mock <ITimer>().Object); _context.Setup(x => x.MessageId).Returns("1"); _context.Setup(x => x.Extensions).Returns(_contextBag); _context.Setup(x => x.MessageHeaders).Returns(new Dictionary <string, string> { [Headers.MessageIntent] = MessageIntentEnum.Send.ToString() }); _context.Setup(x => x.Message).Returns(new LogicalMessage(new global::NServiceBus.Unicast.Messages.MessageMetadata(typeof(Messages.ICommand)), 1)); _executor = new Internal.UnitOfWorkExecutor(_metrics.Object); }
public FakeCakeContext() { testsDir = new DirectoryPath( System.IO.Path.GetFullPath(AppContext.BaseDirectory)); var fileSystem = new FileSystem(); log = new FakeLog(); var runtime = new CakeRuntime(); var platform = new FakePlatform(PlatformFamily.Windows); var environment = new CakeEnvironment(platform, runtime); var globber = new Globber(fileSystem, environment); var args = new FakeCakeArguments(); var registry = new WindowsRegistry(); var dataService = new FakeDataService(); var toolRepository = new ToolRepository(environment); var config = new FakeConfiguration(); var toolResolutionStrategy = new ToolResolutionStrategy(fileSystem, environment, globber, config, log); IToolLocator tools = new ToolLocator(environment, toolRepository, toolResolutionStrategy); var processRunner = new ProcessRunner(fileSystem, environment, log, tools, config); context = new CakeContext(fileSystem, environment, globber, log, args, processRunner, registry, tools, dataService, config); context.Environment.WorkingDirectory = testsDir; }
public void IsVisible_WithAllAndNoNameFilter_ReturnsTrueForCompatible() { using (var tidy = new DisposableKSP()) { var config = new FakeConfiguration(tidy.KSP, tidy.KSP.Name); GameInstanceManager manager = new GameInstanceManager( new NullUser(), config ) { CurrentInstance = tidy.KSP }; var ckan_mod = TestData.FireSpitterModule(); var registry = Registry.Empty(); registry.AddAvailable(ckan_mod); var item = new ModList(delegate { }); Assert.That(item.IsVisible( new GUIMod(ckan_mod, registry, manager.CurrentInstance.VersionCriteria()), manager.CurrentInstance.Name )); manager.Dispose(); config.Dispose(); } }
public void WhenArgumentsMatches_should_return_self() { var builtRule = A.Fake <BuildableCallRule>(); var config = new FakeConfiguration(this.fake, builtRule); Assert.That(config.WhenArgumentsMatch(x => true), Is.SameAs(config)); }
public ToolResolutionStrategyFixture() { Environment = FakeEnvironment.CreateUnixEnvironment(); FileSystem = new FakeFileSystem(Environment); Globber = new Globber(FileSystem, Environment); Configuration = new FakeConfiguration(); Repository = new ToolRepository(Environment); }
public IReturnValueArgumentValidationConfiguration <TMember> CreateConfiguration <TMember>(FakeObject fakeObject, BuildableCallRule callRule) { var parent = new FakeConfiguration(fakeObject, callRule); var configuration = new FakeConfiguration.ReturnValueConfiguration <TMember>(); configuration.ParentConfiguration = parent; return(configuration); }
public void AssertWasCalled_should_set_IsAssertion_to_true_of_recorded_rule() { var config = new FakeConfiguration(this.fake, new RecordedCallRule(A.Fake <MethodInfoManager>())); config.AssertWasCalled(x => true); Assert.That(((RecordedCallRule)config.RuleBeingBuilt).IsAssertion, Is.True); }
public void UninstallEmptyDirs() { string emptyFolderName = "DogeCoinFlag"; // Create a new disposable KSP instance to run the test on. using (var ksp = new DisposableKSP()) { var config = new FakeConfiguration(ksp.KSP, ksp.KSP.Name); GameInstanceManager manager = new GameInstanceManager( new NullUser(), config ) { CurrentInstance = ksp.KSP }; string directoryPath = Path.Combine(ksp.KSP.game.PrimaryModDirectory(ksp.KSP), emptyFolderName); // Install the base test mod. var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); registry.AddAvailable(TestData.DogeCoinFlag_101_module()); List<string> modules = new List<string> { TestData.DogeCoinFlag_101_module().identifier }; HashSet<string> possibleConfigOnlyDirs = null; CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs); modules.Clear(); // Install the plugin test mod. manager.Cache.Store(TestData.DogeCoinPlugin_module(), TestData.DogeCoinPluginZip()); registry.AddAvailable(TestData.DogeCoinPlugin_module()); modules.Add(TestData.DogeCoinPlugin_module().identifier); CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs); modules.Clear(); // Check that the directory is installed. Assert.IsTrue(Directory.Exists(directoryPath)); // Uninstall both mods. modules.Add(TestData.DogeCoinFlag_101_module().identifier); modules.Add(TestData.DogeCoinPlugin_module().identifier); CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(modules, ref possibleConfigOnlyDirs, CKAN.RegistryManager.Instance(manager.CurrentInstance)); // Check that the directory has been deleted. Assert.IsFalse(Directory.Exists(directoryPath)); manager.Dispose(); config.Dispose(); } }
public LoginControllerTest() { _validator = Substitute.For <IValidator <LoginDTO> >(); _sim = Substitute.For <FakeSignInManager>(); _um = Substitute.For <FakeUserManager>(); var config = FakeConfiguration.Get(); _sut = new LoginController(_validator, _sim, _um, config); }
public void AssertWasCalled_should_set_repeat_predicate_to_the_recorded_rule() { Func <int, bool> repeatPredicate = x => true; var config = new FakeConfiguration(this.fake, new RecordedCallRule(A.Fake <MethodInfoManager>())); config.AssertWasCalled(repeatPredicate); Assert.That(((RecordedCallRule)config.RuleBeingBuilt).RepeatPredicate, Is.SameAs(repeatPredicate)); }
public RegisterControllerTest() { _userRepository = Substitute.For <IUserRepository>(); _registerValidator = Substitute.For <IValidator <RegisterDTO> >(); _um = Substitute.For <FakeUserManager>(); var config = FakeConfiguration.Get(); _sut = new RegisterController(_userRepository, _registerValidator, _um, config); }
public void WhenArgumentsMatches_from_VB_should_be_null_guarded() { var builtRule = A.Fake <BuildableCallRule>(); var config = new FakeConfiguration(this.fake, builtRule) as FakeItEasy.VisualBasic.IVisualBasicConfigurationWithArgumentValidation; NullGuardedConstraint.Assert(() => config.WhenArgumentsMatch(x => true)); }
public void WhenArgumentsMatches_should_be_null_guarded() { var builtRule = A.Fake <BuildableCallRule>(); var config = new FakeConfiguration(this.fake, builtRule); NullGuardedConstraint.Assert(() => config.WhenArgumentsMatch(x => true)); }
public void AspNetCoreAddSwaggerGen_DoesNotThrowException() { // Arrange var serviceCollection = new ServiceCollection(); var configuration = new FakeConfiguration(); // Act & Assert serviceCollection.AddSwaggerGen(configuration); serviceCollection.BuildServiceProvider(); }
public void WhenArgumentsMatches_from_VB_should_return_configuration_object() { var builtRule = A.Fake <BuildableCallRule>(); var config = new FakeConfiguration(this.fake, builtRule) as FakeItEasy.VisualBasic.IVisualBasicConfigurationWithArgumentValidation; var returned = config.WhenArgumentsMatch(x => true); Assert.That(returned, Is.SameAs(config)); }
public void Setup() { _store = new Moq.Mock <IStoreEvents>(); _mapper = new Moq.Mock <IEventMapper>(); _mapper.Setup(x => x.GetMappedTypeFor(typeof(Event))).Returns(typeof(Event)); var fake = new FakeConfiguration(); fake.FakeContainer.Setup(x => x.Resolve <IEventMapper>()).Returns(_mapper.Object); Configuration.Settings = fake; }
public void CanInstallMod() { string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png"; // Create a new disposable KSP instance to run the test on. using (DisposableKSP ksp = new DisposableKSP()) { var config = new FakeConfiguration(ksp.KSP, ksp.KSP.Name); GameInstanceManager manager = new GameInstanceManager( new NullUser(), config ) { CurrentInstance = ksp.KSP }; // Make sure the mod is not installed. string mod_file_path = Path.Combine(ksp.KSP.game.PrimaryModDirectory(ksp.KSP), mod_file_name); Assert.IsFalse(File.Exists(mod_file_path)); // Copy the zip file to the cache directory. Assert.IsFalse(manager.Cache.IsCachedZip(TestData.DogeCoinFlag_101_module())); string cache_path = manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); Assert.IsTrue(manager.Cache.IsCachedZip(TestData.DogeCoinFlag_101_module())); Assert.IsTrue(File.Exists(cache_path)); // Mark it as available in the registry. var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; Assert.AreEqual(0, registry.CompatibleModules(ksp.KSP.VersionCriteria()).Count()); registry.AddAvailable(TestData.DogeCoinFlag_101_module()); Assert.AreEqual(1, registry.CompatibleModules(ksp.KSP.VersionCriteria()).Count()); // Attempt to install it. List <string> modules = new List <string> { TestData.DogeCoinFlag_101_module().identifier }; HashSet <string> possibleConfigOnlyDirs = null; new CKAN.ModuleInstaller(ksp.KSP, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs); // Check that the module is installed. Assert.IsTrue(File.Exists(mod_file_path)); manager.Dispose(); config.Dispose(); } }
public NuGetLoadDirectiveProviderFixture() { Environment = FakeEnvironment.CreateUnixEnvironment(); Installer = Substitute.For <INuGetPackageInstaller>(); Configuration = new FakeConfiguration(); Log = new FakeLog(); Reference = new LoadReference(new Uri("nuget:?package=Cake.Recipe")); InstallResult = new List <FilePath>(); Context = Substitute.For <IScriptAnalyzerContext>(); Context.Root.Returns(new FilePath("/Working/build.cake")); }
protected virtual void OnSetUp() { this.fake = new FakeObject(typeof(IFoo)); this.expressionRuleFactory = x => { var result = new ExpressionCallRule(new ExpressionCallMatcher(x, A.Fake <ArgumentValidatorFactory>(), A.Fake <MethodInfoManager>())); this.ruleProducedByFactory = result; return(result); }; this.configuration = this.CreateConfiguration(); }
public void MongoClientFactoryCreateClient_ReturnValidClient() { // Arrange var configuration = new FakeConfiguration(); var factory = new MongoClientFactory(); // Act var output = factory.CreateClient(configuration.ConnectionString); // Assert output.Should().NotBeNull(); }
public void Calls_configured_in_a_child_context_does_not_exist_outside_that_context() { var fake = new FakeObject(typeof(IFoo)); var config = new FakeConfiguration <IFoo>(fake); using (Fake.CreateScope()) { config.CallsTo(x => x.Baz()).Returns(10); } Assert.That(((IFoo)fake.Object).Baz(), Is.Not.EqualTo(10)); }
public NuGetModuleFixture() { Registrar = Substitute.For <ICakeContainerRegistrar>(); Builder = Substitute.For <ICakeRegistrationBuilder>(); Configuration = new FakeConfiguration(); Registrar.RegisterType <T>().Returns(Builder); Builder.As(Arg.Any <Type>()).Returns(Builder); Builder.Singleton().Returns(Builder); Builder.Transient().Returns(Builder); Builder.AsSelf().Returns(Builder); }
public void WhenArgumentsMatches_from_VB_should_set_predicate_to_built_rule() { var builtRule = A.Fake <BuildableCallRule>(); var config = new FakeConfiguration(this.fake, builtRule) as FakeItEasy.VisualBasic.IVisualBasicConfigurationWithArgumentValidation; Func <ArgumentCollection, bool> predicate = x => true; config.WhenArgumentsMatch(predicate); Fake.Assert(builtRule) .WasCalled(x => x.UsePredicateToValidateArguments(predicate)); }
public void WhenArgumentsMatches_should_call_UsePredicateToValidateArguments_on_built_rule() { Func <ArgumentCollection, bool> predicate = x => true; var builtRule = A.Fake <BuildableCallRule>(); var config = new FakeConfiguration(this.fake, builtRule); config.WhenArgumentsMatch(predicate); Fake.Assert(builtRule) .WasCalled(x => x.UsePredicateToValidateArguments(predicate)); }
public void SetConfiguration_throws_if_an_attempt_is_made_to_set_a_different_configuration_type() { var manager = CreateManager(); var configuration1 = new FakeConfiguration(); var configuration2 = new Mock<DbConfiguration>().Object; manager.SetConfiguration(configuration1); Assert.Equal( Strings.ConfigurationSetTwice(configuration2.GetType().Name, configuration1.GetType().Name), Assert.Throws<InvalidOperationException>(() => manager.SetConfiguration(configuration2)).Message); }