public void ConfigurationService_Returns_Valid_Configration() { var target = _appHost.TryResolve <ConfigurationService>(); var result = target.Get(new QueryServerSettings()); Assert.IsNotNull(result); Assert.AreEqual(1, result.Id); Assert.IsTrue(result.GitExecutable.Contains("git.exe")); }
public void Can_register_IDtoBValidator_separately() { using (var appHost = new BasicAppHost { ConfigureAppHost = host => { host.RegisterService <DtoAService>(); host.Plugins.Add(new ValidationFeature()); }, ConfigureContainer = c => { c.RegisterAs <DtoBValidator, IDtoBValidator>(); c.RegisterValidators(typeof(DtoARequestValidator).Assembly); } }.Init()) { var dtoAValidator = (DtoARequestValidator)appHost.TryResolve <IValidator <DtoA> >(); Assert.That(dtoAValidator, Is.Not.Null); Assert.That(dtoAValidator.dtoBValidator, Is.Not.Null); Assert.That(appHost.TryResolve <IValidator <DtoB> >(), Is.Not.Null); Assert.That(appHost.TryResolve <IDtoBValidator>(), Is.Not.Null); var result = dtoAValidator.Validate(new DtoA()); Assert.That(result.IsValid, Is.False); Assert.That(result.Errors.Count, Is.EqualTo(1)); result = dtoAValidator.Validate(new DtoA { FieldA = "foo", Items = new[] { new DtoB() }.ToList() }); Assert.That(result.IsValid, Is.False); Assert.That(result.Errors.Count, Is.EqualTo(1)); result = dtoAValidator.Validate(new DtoA { FieldA = "foo", Items = new[] { new DtoB { FieldB = "bar" } }.ToList() }); Assert.That(result.IsValid, Is.True); } }