public async Task UpdateBlog_Return_Ok_Return_UpdatedBlog() { // Arrange HttpResponseMessage expectedRespone = new HttpResponseMessage(System.Net.HttpStatusCode.OK); RubiconContext db = _server.Services.GetService(typeof(RubiconContext)) as RubiconContext; Blog blog = db.Blogs.Take(1).First();//get a random blog that is allready taken DataGeneration data = new DataGeneration(); UpdateBlogModel addBlogModel = new UpdateBlogModel() { Slug = blog.Slug, Body = data.GenerateStringRandomLenght(10, 30), Description = data.GenerateStringRandomLenght(10, 30), Title = data.GenerateStringRandomLenght(10, 30) }; var Client = new RestClient("http://localhost:57595/"); var Request = new RestRequest("api/Posts", Method.PUT).AddJsonBody(addBlogModel); //Act var response = await Client.ExecuteAsync(Request); BlogModel blogModel = new JsonDeserializer().Deserialize <BlogModel>(response); //Arrange Assert.Equal(expectedRespone.StatusCode, response.StatusCode); Assert.True(blogModel != null); }
public void Should_Throw_Excpetion_Bad_Input_Data(int min, int max) { // Arrange // Act // Assert dataGeneration.GenerateStringRandomLenght(min, max); }
public async Task AddBlog_Return_Ok_With_Added_Blog() { // Arrange HttpResponseMessage expectedRespone = new HttpResponseMessage(System.Net.HttpStatusCode.OK); RubiconContext db = _server.Services.GetService(typeof(RubiconContext)) as RubiconContext; Tag tag = db.Tags.Take(1).First(); DataGeneration generator = new DataGeneration(); AddBlogModel addBlogModel = new AddBlogModel() { Body = "ttttt", Description = "tttt", TagList = new List <string>(), Title = generator.GenerateStringRandomLenght(10, 30) }; addBlogModel.TagList.Add(tag.Name); var Client = new RestClient("http://localhost:57595/"); var Request = new RestRequest("api/Posts").AddJsonBody(addBlogModel); //Act var response = await Client.ExecutePostAsync(Request); BlogModel blogsModel = new JsonDeserializer().Deserialize <BlogModel>(response); //Arrange Assert.Equal(expectedRespone.StatusCode, response.StatusCode); Assert.True(blogsModel != null); }