public void Add_WhenLeftSizeIs8000_ShouldSave() { //arrange _context.Database.EnsureCreated(); var differenceLeftRepository = new DifferenceLeftRepository(_context); int id = 1; //Act var differenceSaved = new DifferenceLeft(id, new string('a', 8000)); differenceLeftRepository.Add(differenceSaved); }
public void Add_WhenPropertiesFilled_ShouldSave() { //arrange _context.Database.EnsureCreated(); var differenceLeftRepository = new DifferenceLeftRepository(_context); int id = 1; //Act var differenceSaved = new DifferenceLeft(id, "a"); differenceLeftRepository.Add(differenceSaved); }
public void Add_WhenLeftIsNull_ShouldThrowDbUpdateException() { //Arrange _context.Database.EnsureCreated(); var differenceLeftRepository = new DifferenceLeftRepository(_context); //Act var difference = new DifferenceLeft(1, null); //Assert Exception ex = Assert.Throws <DbUpdateException>(() => differenceLeftRepository.Add(difference)); }
public ActionResult <Difference> PostLeft(DifferenceLeft differenceLeft) { try { _differenceLeftRepository.Add(differenceLeft); return(CreatedAtAction("GetDifferenceLeft", new { id = differenceLeft.Id }, differenceLeft)); } catch (Exception e) { return(StatusCode(500, e)); } }
public async void PostLeft_WhenIdAndBase64Provided_ShoulReturnHttp201() { // Arrange int id = 1; var requestUrl = $"v1/Diff/{id}/left"; var differenceLeft = new DifferenceLeft(id, "ewogICAgImlkIjoxLAogICAgIm5hbWUiOiJ0ZXN0ZSIKfQ=="); // Act var response = await _client.PostAsync(requestUrl, ContentHelper.GetStringContent(differenceLeft)); // Assert Assert.Equal(HttpStatusCode.Created, response.StatusCode); }
public void Add_WhenLeftSizeIs8001_ShouldThrowException() { //arrange _context.Database.EnsureCreated(); var differenceLeftRepository = new DifferenceLeftRepository(_context); int id = 1; //Act var difference = new DifferenceLeft(id, new string('a', 8001)); differenceLeftRepository.Add(difference); //Assert Exception ex = Assert.Throws <DbUpdateException>(() => differenceLeftRepository.Add(difference)); }
public async void GetById_WhenProperlySaved_ShouldReturnEqualValues() { //arrange _context.Database.EnsureCreated(); var differenceLeftRepository = new DifferenceLeftRepository(_context); int id = 1; //Act var differenceSaved = new DifferenceLeft(id, "a"); differenceLeftRepository.Add(differenceSaved); var differenceReturned = await differenceLeftRepository.GetById(id); //Assert Assert.Equal <Difference>(differenceSaved, differenceReturned); }
public async void GetDifferenceLeft_WhenExists_ShoulReturnHttp200() { // Arrange int id = 2; var postUrl = $"v1/Diff/{id}/left"; var differenceleft = new DifferenceLeft(id, "ewogICAgImlkIjoxLAogICAgIm5hbWUiOiJ0ZXN0ZSIKfQ=="); var content = ContentHelper.GetStringContent(differenceleft); await _client.PostAsync(postUrl, content); var requestUrl = postUrl; // Act var response = await _client.GetAsync(requestUrl); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); //TODO: Test for content }
public async void GetDifference_WhenEqualSizeButDifferentValues_ShoulReturnSameSizeButDifferentData() { // Arrange int id = 3; var postUrlLeft = $"v1/Diff/{id}/left"; var differenceleft = new DifferenceLeft(id, "ewogICAgImlkIjoxLAogICAgIm5hbWUiOiJ0ZXN0ZSIKfQ=="); var contentLeft = ContentHelper.GetStringContent(differenceleft); await _client.PostAsync(postUrlLeft, contentLeft); var postUrlRight = $"v1/Diff/{id}/right"; var differenceRight = new DifferenceRight(id, "ewogICAgImlkIjoxLAogICAgIm5hbWUiOiJ0ZXN0ZTIiCn0="); var contentRight = ContentHelper.GetStringContent(differenceRight); await _client.PostAsync(postUrlRight, contentRight); var requestUrl = $"v1/Diff/{id}"; // Act var response = await _client.GetAsync(requestUrl); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); //TODO: Test for content }