private IApplicationService GetMockAppService() { var mockApplicationService = new Mock <IApplicationService>(); mockApplicationService.Setup(x => x.GetApplicationIdFromKey(It.IsAny <string>())).Returns(1); List <AimlDoc> docList = new List <AimlDoc>(); AimlDoc doc = new AimlDoc { appId = 1 }; string name = "AI.aiml"; string path = "./" + name; doc.document = File.ReadAllText(path); doc.name = name; docList.Add(doc); mockApplicationService.Setup(x => x.GetAimlDocs(It.IsAny <int>())).Returns(docList); return(mockApplicationService.Object); }
public void UpdateAimlDocument(int appId, string name, string document) { UnitOfWork uow = new UnitOfWork(); AimlDoc doc = uow.AimlDocRepository.GetItem(a => a.appId == appId && a.name == name).SingleOrDefault(); if (doc == null) { uow.AimlDocRepository.Insert(new AimlDoc() { appId = appId, name = name, document = document }); uow.Save(); } else { doc.document = document; uow.AimlDocRepository.Update(doc); uow.Save(); } }