public void PostPoll_ShouldReturnCorrectObject() { // Arrange var pollPostVm = new PollPostVM() { Description = "Poll", Options = new string[] { "Option1", "Option2" } }; // Act var result1 = _pollController.PostPoll(pollPostVm); var result2 = _pollController.PostPoll(pollPostVm); // Assert Assert.IsInstanceOfType(result1.Result, typeof(CreatedAtActionResult)); Assert.IsInstanceOfType(result2.Result, typeof(CreatedAtActionResult)); var expected1 = ((CreatedAtActionResult)result1.Result).Value; var expected2 = ((CreatedAtActionResult)result2.Result).Value; Assert.AreEqual(1, expected1.GetType().GetProperty("poll_id").GetValue(expected1)); Assert.AreEqual(2, expected2.GetType().GetProperty("poll_id").GetValue(expected2)); }