public async Task NotifyUpdatedColidEntryToSubscribers_Put_Returns_Ok() { _seeder.ClearUsers(); _seeder.SeedMessageTemplates(); // IMPORTANT: User needs to be new, and not persisted already, even if it doesn't make sense ... // thats the reason userEntity is commented. IF you add it before the subscription, another user will be tried // so add. Don't ask me why .. Alternatively you can add a new subscription to the user before creation: /* * var template = TestData.GenerateSampleMessageTemplateForColidEntrySubscriptionUpdate(); * var templateEntity = _seeder.Add(template); * var subscription = TestData.GenerateRandomColidEntrySubscription(); * var user = TestData.GenerateRandomUser(); * user.ColidEntrySubscriptions = new Collection<ColidEntrySubscription>() { subscription }; * var userEntity = _seeder.Add(user); */ var user = TestData.GenerateRandomUser(); var subscription = TestData.GenerateRandomColidEntrySubscription(); subscription.User = user; _seeder.Add(subscription); var colidEntryDto = new ColidEntryDtoBuilder().WithColidPidUri(subscription.ColidPidUri).WithLabel("Hugo Boss Maximum fragrance").Build(); var response = await Client.PutAsync($"{PATH}", _api.BuildJsonHttpContent(colidEntryDto)); var stringResponse = await response.Content.ReadAsStringAsync(); _output.WriteLine(stringResponse); response.EnsureSuccessStatusCode(); Assert.Contains("1", stringResponse); }
public async Task Post_Returns_OK() { var cg = TestData.GenerateRandomConsumerGroupDto(); var response = await Client.PostAsync(PATH, _api.BuildJsonHttpContent(cg)); var stringResponse = await response.Content.ReadAsStringAsync(); _output.WriteLine(stringResponse); Assert.Equal(HttpStatusCode.Created, response.StatusCode); response.EnsureSuccessStatusCode(); var responseCg = JsonConvert.DeserializeObject <ConsumerGroup>(stringResponse); Assert.NotNull(responseCg); Assert.NotEqual(0, responseCg.Id); Assert.Equal(cg.Uri, responseCg.Uri); }
public async Task WelcomeMessageEditor_Update_Returns_Ok() { var originalContent = _welcomeMessageEditor.Content; var updatedContent = "<h1>this is the new content</h1>"; var response = await Client.PutAsync($"{PATH}/editor", _api.BuildJsonHttpContent(updatedContent)); var stringResponse = await response.Content.ReadAsStringAsync(); _output.WriteLine(stringResponse); response.EnsureSuccessStatusCode(); var responseMessage = JsonConvert.DeserializeObject <WelcomeMessage>(stringResponse); Assert.NotNull(responseMessage); Assert.NotEqual(originalContent, responseMessage.Content); Assert.Equal(updatedContent, responseMessage.Content); _seeder.ResetWelcomeMessages(); }
public async Task Post_Returns_OK() { _seeder.ClearMessageTemplates(); // so no templates are in DB var tpl = TestData.GenerateSampleMessageTemplateForColidEntrySubscriptionUpdateDto(); var response = await Client.PostAsync(PATH, _api.BuildJsonHttpContent(tpl)); var stringResponse = await response.Content.ReadAsStringAsync(); _output.WriteLine(stringResponse); Assert.Equal(HttpStatusCode.Created, response.StatusCode); response.EnsureSuccessStatusCode(); var responseTemplate = JsonConvert.DeserializeObject <MessageTemplate>(stringResponse); Assert.NotNull(responseTemplate); Assert.NotEqual(0, responseTemplate.Id); Assert.Equal(tpl.Type, responseTemplate.Type); Assert.Equal(tpl.Subject, responseTemplate.Subject); Assert.Equal(tpl.Body, responseTemplate.Body); _seeder.ResetMessageTemplates(); }
public async Task BroadCastMessage_Calls_MessageService_Returns_Ok() { _seeder.ResetUsers(); _seeder.AssignMessageConfigToAllUsers(); var users = _seeder.GetAll <User>(nameof(User.MessageConfig)); // ACT var broadCastMessageToSend = new BroadcastMessageDto("TestSubject", "TestBody"); var response = await Client.PostAsync($"{PATH}/broadcastMessage", _api.BuildJsonHttpContent(broadCastMessageToSend)); var stringResponse = await response.Content.ReadAsStringAsync(); _output.WriteLine(stringResponse); response.EnsureSuccessStatusCode(); // ASSERT Assert.NotEmpty(stringResponse); Assert.Equal(HttpStatusCode.OK, response.StatusCode); }