示例#1
0
 public HomeController()
 {
     if (greetingRepository == null)
     {
         greetingRepository = new GreetingRepository();
     }
 }
示例#2
0
        public IActionResult Get(string lang)
        {
            var repository = new GreetingRepository();
            var greeting   = repository.GetGreeting(lang);

            if (greeting == null)
            {
                return(NotFound());
            }

            return(Ok(greeting));
        }
        public void AddCustomerContentTest() // ADD CUSTOMER TO EMAIL LIST TEST
        {
            //ARRANGE
            CustomerContent        content   = new CustomerContent();
            GreetingRepository     repo      = new GreetingRepository();
            List <CustomerContent> localList = repo.GetContentList();

            // ACT
            int beforeCount = localList.Count;

            repo.AddContentToList(content);
            int actual   = localList.Count;
            int expected = beforeCount + 1;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void UpdateCustomerContentTest() // EDIT CUSTOMER CONTENT TEST
        {
            // ARRANGE
            GreetingRepository repo = new GreetingRepository();

            CustomerContent oldContent = new CustomerContent("Gandalf", "Thegrey", CustomerType.Potential, "We currently have the lowest rates on Helicopter Insurance!", "Gandalf Thegrey");

            repo.AddContentToList(oldContent);

            CustomerContent updatedcontent = new CustomerContent("Tom", "Bombadill", CustomerType.Past, "It's been a long time since we've heard from you, we want you back.", "Tom Bombadill");

            string name = "gandalf thegrey";

            //ACT
            bool result = repo.UpdateCustomerContent(name, updatedcontent);

            //ASSERT
            Assert.IsTrue(result);
        }
示例#5
0
        public void ReturnNullIfUnknownLanguage()
        {
            var repository = new GreetingRepository();

            Assert.Null(repository.GetGreeting("unknown-language"));
        }
示例#6
0
        public void ReturnGreetingMessage(string language, string greeting)
        {
            var repository = new GreetingRepository();

            Assert.Equal(greeting, repository.GetGreeting(language));
        }