public void TearDown() { //clear cache after each test var cache = appHost.TryResolve <ICacheClient>(); cache.FlushAll(); }
public void Can_register_Custom_User_and_Register_Service() { var client = new JsonServiceClient(Config.ListeningOn); var response = client.Send(new RegisterUser { Email = "*****@*****.**", DisplayName = "Test User", FirstName = "Test", LastName = "User", NetworkName = nameof(RegisterUser), Password = Password, ConfirmPassword = Password, }); var authRepo = appHost.TryResolve <IAuthRepository>(); var newUser = (MyUser)authRepo.GetUserAuth(response.UserId); Assert.That(newUser.Email, Is.EqualTo("*****@*****.**")); Assert.That(newUser.NetworkName, Is.EqualTo(nameof(RegisterUser))); var authResponse = client.Send(new Authenticate { provider = "credentials", UserName = newUser.Email, Password = Password, RememberMe = true, }); Assert.That(authResponse.DisplayName, Is.EqualTo("Test User")); }
public void Setup() { using (var db = appHost.TryResolve <IDbConnectionFactory>().Open()) { db.DropAndCreateTable <Country>(); db.DropAndCreateTable <Sms>(); db.Insert(new Country { Name = "Germany", Mcc = "262", Cc = "49", PricePerSMS = 0.55m }); db.Insert(new Country { Name = "Austria", Mcc = "232", Cc = "43", PricePerSMS = 0.53m }); db.Insert(new Country { Name = "Poland", Mcc = "260", Cc = "48", PricePerSMS = 0.32m }); } }
public void Setup() { using (var db = appHost.TryResolve <IDbConnectionFactory>().Open()) { db.DropAndCreateTable <Sms>(); } }
public void TestFixtureSetUp() { appHost = new RedisMqAppHost() .Init() .Start(ListeningOn); using (var redis = appHost.TryResolve<IRedisClientsManager>().GetClient()) redis.FlushAll(); }
public void Can_Get_Countries() { using (var service = appHost.TryResolve <CountryServices>()) { var response = service.Get(new ServiceModel.Countries()).GetResult(); Assert.That(response.Count, Is.EqualTo(3)); Assert.That(response.Map(c => c.Name), Is.EquivalentTo(new[] { "Germany", "Austria", "Poland" })); } }
protected void AssertUsedNewPasswordHasher(IUserAuth user) { Assert.That(user.PasswordHash != null && user.Salt == null); byte[] decodedHashedPassword = Convert.FromBase64String(user.PasswordHash); Assert.That(decodedHashedPassword[0], Is.EqualTo(0x01)); Assert.That(appHost.TryResolve <IPasswordHasher>().Version, Is.EqualTo(0x01)); }
public void Can_send_Email_to_TestContact() { using (var db = appHost.TryResolve <IDbConnectionFactory>().Open()) using (var service = appHost.TryResolve <EmailServices>()) { var contact = db.Single <Contact>(q => q.Email == "*****@*****.**"); var response = service.Any( new EmailContact { ContactId = contact.Id, Subject = "Test Subject" }); Assert.That(response.Email, Is.EqualTo(contact.Email)); var email = db.Single <Email>(q => q.To == contact.Email); Assert.That(email.Subject, Is.EqualTo("Test Subject")); } }
public void Does_send_to_DLQ_when_thrown_from_void_Service() { using (var mqFactory = appHost.TryResolve <IMessageFactory>()) { var request = new ThrowVoid { Content = "Test" }; using (var mqProducer = mqFactory.CreateMessageProducer()) using (var mqClient = mqFactory.CreateMessageQueueClient()) { mqProducer.Publish(request); var msg = mqClient.Get <ThrowVoid>(QueueNames <ThrowVoid> .Dlq, null); mqClient.Ack(msg); Assert.That(msg.Error.ErrorCode, Is.EqualTo("InvalidOperationException")); } } }
public void Can_Publish_to_AnyTestMq_Service() { using (var mqFactory = appHost.TryResolve <IMessageFactory>()) { var request = new AnyTestMq { Id = 1 }; using (var mqProducer = mqFactory.CreateMessageProducer()) mqProducer.Publish(request); using (var mqClient = mqFactory.CreateMessageQueueClient()) { var msg = mqClient.Get <AnyTestMqResponse>(QueueNames <AnyTestMqResponse> .In, null); mqClient.Ack(msg); Assert.That(msg.GetBody().CorrelationId, Is.EqualTo(request.Id)); } } }
public void TestFixtureSetUp() { appHost = new RabbitMqAppHost() .Init() .Start(ListeningOn); using (var conn = appHost.TryResolve<ConnectionFactory>().CreateConnection()) using (var channel = conn.CreateModel()) { channel.PurgeQueue<AnyTestMq>(); channel.PurgeQueue<AnyTestMqResponse>(); channel.PurgeQueue<PostTestMq>(); channel.PurgeQueue<PostTestMqResponse>(); channel.PurgeQueue<ValidateTestMq>(); channel.PurgeQueue<ValidateTestMqResponse>(); channel.PurgeQueue<ThrowGenericError>(); } }
public void Can_write_ValidateRequestAttribute() { var nativeTypes = appHost.AssertPlugin <NativeTypesFeature>(); var gen = nativeTypes.DefaultGenerator; var attr = new ValidateRequestAttribute("HasRole('Accounts')") { ErrorCode = "ExCode", Message = "'Id' Is Required", }; var metaAttr = gen.ToAttribute(attr); string argValue(string name) => metaAttr.Args.First(x => x.Name == name).Value; Assert.That(metaAttr.Name, Is.EqualTo("ValidateRequest")); Assert.That(metaAttr.Args.Count, Is.EqualTo(3)); Assert.That(argValue(nameof(ValidateRequestAttribute.Validator)), Is.EqualTo("HasRole('Accounts')")); Assert.That(argValue(nameof(ValidateRequestAttribute.ErrorCode)), Is.EqualTo("ExCode")); Assert.That(argValue(nameof(ValidateRequestAttribute.Message)), Is.EqualTo("'Id' Is Required")); var csharp = new CSharpGenerator(new MetadataTypesConfig { DefaultNamespaces = new List <string> { "ServiceStack" } }); var src = csharp.GetCode(new MetadataTypes { Types = new List <MetadataType> { new MetadataType { Name = "TheType", Attributes = new List <MetadataAttribute> { metaAttr, } } } }, new BasicRequest(), appHost.TryResolve <INativeTypesMetadata>()); src.Print(); Assert.That(src, Does.Contain( "[ValidateRequest(\"HasRole('Accounts')\", ErrorCode=\"ExCode\", Message=\"'Id' Is Required\")]")); }
public void ShouldHaveRegisteredAuthenticateService() { var subject = _appHost.TryResolve <AuthenticateService>(); Assert.NotNull(subject); }
public void TestFixtureTearDown() { ((IClearable)appHost.TryResolve <IAuthRepository>()).Clear(); //Flush InMemoryAuthProvider appHost.Dispose(); }
public void SetUp() { var serverEvents = appHost.TryResolve <IServerEvents>(); serverEvents.Reset(); }