public void TestPostAssociatedOccurrenceNegative() { var param = new PostAssociatedOccurrencesParams { OccurrenceId = 20, TypeOfAssociation = "like" }; var AssociatedDTO = new AssociatedOccurrencesDTO { ApplicationUserId = _testUser.Id, Id = 500, OccurrenceId = 20, Type = "like" }; var associated1 = new AssociatedOccurrences { ApplicationUser = _testUser, Id = 30, ApplicationUserId = _testUser.Id, Type = "like", OccurrenceId = 20 }; _occurrencesList.Add(associated1); _mockMapper.Setup(x => x.Map <AssociatedOccurrencesDTO>(It.IsAny <AssociatedOccurrences>())).Returns(AssociatedDTO); var response = _controller.PostAssociatedOccurrence(param).Result; var okResult = response.Should().BeOfType <BadRequestObjectResult>().Subject; }
public void TestPostAssociatedOccurrencePositive() { var param = new PostAssociatedOccurrencesParams { OccurrenceId = 20, TypeOfAssociation = "like" }; var AssociatedDTO = new AssociatedOccurrencesDTO { ApplicationUserId = _testUser.Id, Id = 500, OccurrenceId = 20, Type = "like" }; var associated1 = new AssociatedOccurrences { ApplicationUser = _testUser, Id = 30, ApplicationUserId = _testUser.Id, Type = "like", OccurrenceId = 1 }; _occurrencesList.Add(associated1); _mockMapper.Setup(x => x.Map <AssociatedOccurrencesDTO>(It.IsAny <AssociatedOccurrences>())).Returns(AssociatedDTO); var response = _controller.PostAssociatedOccurrence(param).Result; var okResult = response.Should().BeOfType <OkObjectResult>().Subject; var occurrences = okResult.Value.Should().BeAssignableTo <AssociatedOccurrencesDTO>().Subject; occurrences.ApplicationUserId.Should().Be("testID"); occurrences.Type.Should().Be("like"); occurrences.Id.Should().Be(500); occurrences.OccurrenceId.Should().Be(20); }