public void GetCloseoutReasonsForLangauge() { var reasons = new List<CloseoutReason> { new CloseoutReason() {Id = 12345, Name = "test1"}, new CloseoutReason() {Id = 67890, Name = "test2"} }; var checkItem = new DictionaryDataItem { Id = (int) reasons[0].Id }; var closeoutReasonDaoStub = new Mock<ICloseoutReasonDao>(); closeoutReasonDaoStub.Setup(y => y.GetAllActive(It.IsAny<CloseoutReasonType>())) .Returns(reasons); var dictionaryStub = new Mock<IDictionaryManager>(); dictionaryStub.Setup( x => x.GetDictionaryItemByKeysAndCultures(new List<string> { reasons[0].Name }, It.IsAny<List<string>>())) .Returns(new List<DictionaryDataItem> { checkItem }); dictionaryStub.Setup( x => x.DictionaryInstanceToContentByCulture(It.IsAny<List<DictionaryInstance>>(), It.IsAny<string>())) .Returns(reasons[0].Name); var manager = new DiaryDataRetrievalManager { CloseoutReasonDao = closeoutReasonDaoStub.Object , DictionaryManager = dictionaryStub.Object }; var closeoutReasons = manager.GetCloseoutReasons(new CloseoutReasonType(), "En-GB"); Assert.AreEqual(closeoutReasons[0].Id, checkItem.Id, "Check that the items id is correct."); }
public void GetCloseoutReasonsFoLangaugeTranslationDoesNonExist() { var langauages = new List<string> { "En-GB" }; var reasons = new List<CloseoutReason> { new CloseoutReason() {Id = 12345, Name = "test1"} }; var closeoutReasonDaoStub = new Mock<ICloseoutReasonDao>(); closeoutReasonDaoStub.Setup(y => y.GetAllActive(It.IsAny<CloseoutReasonType>())) .Returns(reasons); var dictionaryStub = new Mock<IDictionaryManager>(); dictionaryStub.Setup( x => x.GetDictionaryItemByKeysAndCultures(It.IsAny<List<string>>(), It.IsAny<List<string>>())) .Returns(new List<DictionaryDataItem>() ); dictionaryStub.Setup( x => x.DictionaryInstanceToContentByCulture(It.IsAny<List<DictionaryInstance>>(), It.IsAny<string>())) .Returns(string.Empty); var manager = new DiaryDataRetrievalManager { CloseoutReasonDao = closeoutReasonDaoStub.Object , DictionaryManager = dictionaryStub.Object }; var closeoutReasons = manager.GetCloseoutReasons(new CloseoutReasonType(), langauages[0]); Assert.AreEqual(closeoutReasons[0].Name, string.Empty, "Check that the items name is null is correct."); }
public void GetEmptyCloseoutReasons() { const CloseoutReasonType REASON_TYPE = CloseoutReasonType.Allocation; var closeoutReasonDaoStub = new Mock<ICloseoutReasonDao>(); closeoutReasonDaoStub.Setup(y => y.GetAllActive(REASON_TYPE)) .Returns(new List<CloseoutReason>()); var dictionaryStub = new Mock<IDictionaryManager>(); dictionaryStub.Setup( x => x.GetDictionaryItemByKeysAndCultures(It.IsAny<List<string>>(), It.IsAny<List<string>>())) .Returns(new List<DictionaryDataItem> { new DictionaryDataItem {Id=12345} }); var manager = new DiaryDataRetrievalManager { CloseoutReasonDao = closeoutReasonDaoStub.Object ,DictionaryManager = dictionaryStub.Object }; var closeoutReasons = manager.GetCloseoutReasons(REASON_TYPE, "En-GB"); Assert.AreEqual(0, closeoutReasons.Count, "Check that correct number of Closeout reasons are returned."); }