public void Contact() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.Contact() as ViewResult; // Assert Assert.IsNotNull(result); }
public void Contact() { // Arrange var config = new ConfigurationRoot(new List<IConfigurationProvider> {new MemoryConfigurationProvider(new MemoryConfigurationSource())}); config["kEY1"] = "keyValue1"; config["key2"] = "keyValue2"; config["USERNAME"] = "******"; var otherSettings = new OtherSettings { Numbers = new int[] { 234, 567 } }; var options = new OptionsWrapper<OtherSettings>(otherSettings); var loggerFactory = new LoggerFactory(); var logger = loggerFactory.CreateLogger<HomeController>(); IMemoryCache cache = new MemoryCache(new MemoryCacheOptions()); HomeController controller = new HomeController(config, options, logger, cache); // Act ViewResult result = controller.Contact() as ViewResult; // Assert Assert.Equal("keyValue1 SNeagu 234, 567", result.ViewBag.Message); }