public void GetGameDetails_GetsInvalidGameKey_ReturnsEmptyJson() { // Arrange var mock = new Mock <IStoreService>(); mock.Setup(a => a.GetGame(It.IsAny <string>())).Throws(new ValidationException("", "")); var sut = new GamesController(mock.Object, _loggerMock.Object); // Act var res = sut.GetDetails("invalid-key"); // Assert Assert.That(res, Is.TypeOf(typeof(JsonResult))); Assert.That(res.Data, Is.Null.Or.Empty); }
public void GetGameDetails_GetsValidGameKey_ReturnsGameJson() { // Arrange var mock = new Mock <IStoreService>(); mock.Setup(a => a.GetGame(It.IsAny <string>())).Returns(new GameDTO()); var sut = new GamesController(mock.Object, _loggerMock.Object); // Act var res = sut.GetDetails("valid-key"); // Assert Assert.That(res, Is.TypeOf(typeof(JsonResult))); Assert.That(res.Data, Is.TypeOf(typeof(GameViewModel))); Assert.That(res.Data as GameViewModel, Is.Not.Null); }