public DocumentTypesServiceTests() { long Id = singleEntity.Id; Mock = DefaultContextMock.GetMock(); MockSet = SetUpMock.SetUpFor(testEntities); Mock.Setup(c => c.Set <DocumentType>()).Returns(MockSet.Object); Mock.Setup(c => c.DocumentType).Returns(MockSet.Object); testedService = new DocumentTypesService(Mock.Object); }
public DocumentTypesServiceTests() { var mockRepository = new Mock <IRepository <DocumentType, int> >(); var mockUnitOfWork = new Mock <IUnitOfWork>(); fakeDocumentTypes = new List <DocumentType> { new DocumentType { Id = 5, Name = "Test1" }, new DocumentType { Id = 7, Name = "Test2" }, new DocumentType { Id = int.MaxValue, Name = "Test2" } }; documentTypesDto = new DocumentTypeDto { Id = 3, Name = "TestDTO" }; mockRepository.Setup(m => m.GetAll()).Returns(fakeDocumentTypes.AsQueryable); mockRepository.Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => fakeDocumentTypes.Single(t => t.Id == id)); mockRepository.Setup(r => r.Create(It.IsAny <DocumentType>())) .Callback <DocumentType>(t => fakeDocumentTypes.Add(documentType = t)); mockRepository.Setup(r => r.Update(It.IsAny <DocumentType>())) .Callback <DocumentType>(t => documentType = t); mockRepository.Setup(x => x.Delete(It.IsAny <int>())) .Callback <int>(id => fakeDocumentTypes.Remove(fakeDocumentTypes.Single(t => t.Id == id))); mockUnitOfWork.Setup(m => m.DocumentTypes).Returns(mockRepository.Object); documentTypesService = new DocumentTypesService(mockUnitOfWork.Object); }
public Transaction GetById(int id) { DocumentsService _documentsService = new DocumentsService(); Transaction t = null; Dictionary <int, Milestone> milestoneDictionary = null; Dictionary <int, TaskBase> taskDictionary = null; Dictionary <int, Chat> chatDictionary = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Transactions_SelectById" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Id", id); } , map : delegate(IDataReader reader, short set) { switch (set) { case 0: t = mapTransaction(reader); break; case 1: int transactionId = 0; Milestone m = MilestonesService.MapMilestone(reader, out transactionId); if (t.Milestones == null) { t.Milestones = new List <Milestone>(); } t.Milestones.Add(m); if (milestoneDictionary == null) { milestoneDictionary = new Dictionary <int, Milestone>(); } milestoneDictionary.Add(m.Id, m); break; case 2: int milestoneId = 0; TaskBase ta = TasksService.MapTask(reader, out milestoneId); Milestone parentMilestone = milestoneDictionary[milestoneId]; if (parentMilestone.Tasks == null) { parentMilestone.Tasks = new List <TaskBase>(); } parentMilestone.Tasks.Add(ta); if (taskDictionary == null) { taskDictionary = new Dictionary <int, TaskBase>(); } taskDictionary.Add(ta.Id, ta); break; case 3: int taskId = 0; Document d = _documentsService.MapDocument(reader, out taskId); TaskBase parentTask = taskDictionary[taskId]; if (parentTask.Documents == null) { parentTask.Documents = new List <Document>(); } parentTask.Documents.Add(d); break; case 4: ParticipantBase pb = _participantsService.MapParticipantBase(reader); if (t.Participants == null) { t.Participants = new List <ParticipantBase>(); } t.Participants.Add(pb); break; case 5: RoleBase rb = MapRoleBases(reader); if (t.Roles == null) { t.Roles = new List <RoleBase>(); } t.Roles.Add(rb); break; case 6: PendingDocument pd = PendingDocumentService.MapPendingDocument(reader); if (t.PendingDocuments == null) { t.PendingDocuments = new List <PendingDocument>(); } t.PendingDocuments.Add(pd); break; case 7: DocumentType dt = DocumentTypesService.MapDocumentType(reader); if (t.DocumentTypes == null) { t.DocumentTypes = new List <DocumentType>(); } t.DocumentTypes.Add(dt); break; case 8: int chatTaskId = 0; Chat ch = ChatService.ChatMapper(reader, out chatTaskId); TaskBase chatParentTask = taskDictionary[chatTaskId]; if (chatParentTask.Chats == null) { chatParentTask.Chats = new List <Chat>(); } chatParentTask.Chats.Add(ch); if (chatDictionary == null) { chatDictionary = new Dictionary <int, Chat>(); } chatDictionary.Add(ch.Id, ch); break; case 9: int chatId = 0; ChatMessage cm = ChatService.MessageMapper(reader, out chatId); Chat parentChat = chatDictionary[chatId]; if (parentChat.Message == null) { parentChat.Message = new List <ChatMessage>(); } parentChat.Message.Add(cm); break; case 10: TransactionDetails listingDetails = MapTransactionDetails(reader); t.ListingDetails = listingDetails; break; case 11: PersonBase buyer = MapBuyer(reader); if (t.Buyers == null) { t.Buyers = new List <PersonBase>(); } t.Buyers.Add(buyer); break; case 12: ListingAgentInfo listAgent = MapListingAgentInfo(reader); t.ListingAgent = listAgent; break; } } ); return(t); }
public MaidDocumentsController(IUnitOfWork unitOfWork, MaidDocumentsService service, DocumentTypesService documentTypesService) : base(unitOfWork, service) { _documentTypesService = documentTypesService; }