public void SearchFightControllerReturnsValidViewModel() { //Arrange var fakeQueryMaker = new QueryMakerMock(); var searchFightCon = new SearchFightController(fakeQueryMaker); //Act var sampleInput = new string[] { ".net", "java" }; var viewModel = searchFightCon.StartSearchFight(sampleInput); //Assert var expectedViewModel = new ViewModel.SearchResult[] { new ViewModel.SearchResult { SearchEngineUsed = "Google", NumberOfResults = 1000, ProgrammingLanguage = ".net" }, new ViewModel.SearchResult { SearchEngineUsed = "MSNSearch", NumberOfResults = 2000, ProgrammingLanguage = ".net" }, new ViewModel.SearchResult { SearchEngineUsed = "Google", NumberOfResults = 1000, ProgrammingLanguage = "java" }, new ViewModel.SearchResult { SearchEngineUsed = "MSNSearch", NumberOfResults = 2000, ProgrammingLanguage = "java" } }; Assert.AreEqual(viewModel.Count(), expectedViewModel.Count()); foreach (var searchResult in viewModel) { Assert.IsTrue(searchResult.NumberOfResults > 0); int pos = Array.IndexOf(sampleInput, searchResult.ProgrammingLanguage); Assert.IsTrue(pos > -1); } }
static void Main(string[] programmingLanguages) { //Resolve Dependencies var container = SearchFightContainer.BuildContainer(); var queryMaker = container.GetInstance <IQueryMaker>(); //Call Controller try { var searchFightCon = new SearchFightController(queryMaker); var viewModel = searchFightCon.StartSearchFight(programmingLanguages); ResultsPrinter.Print(viewModel); } catch (Exception ex) { Console.WriteLine(ex.Message); } }