public async Task TestMethod1() { IWindsorContainer container = Container.Configure(); UZTask createdTask; using (TaskContext taskContext = new TaskContext()) { createdTask = new UZTask(); createdTask.Id = Guid.NewGuid(); createdTask.Title = "Test title"; taskContext.Tasks.Add(createdTask); await taskContext.SaveChangesAsync(); } using (IDomainUnitOfWork <Guid, UZTask, IRepository <Guid, UZTask> > unitOfWork = container.Resolve <IDomainUnitOfWork <Guid, UZTask, IRepository <Guid, UZTask> > >()) { var task = await unitOfWork.Repository.GetByIdAsync(createdTask.Id); task.Object.Title = "Changed title"; await unitOfWork.CommitAsync(); } using (TaskContext taskContext = new TaskContext()) { taskContext.Database.Log = t => Debug.WriteLine(t); List <string> items = new List <string> { "Changed title" }; IQueryable <UZTask> tasks = taskContext.Tasks.Where(t => items.Contains(t.Title)); /* UZTask task1 = tasks.First(); * task1.Title = "Change title 2";*/ await taskContext.SaveChangesAsync(); } }
public void TaskIsUnique() { UZTask t1 = new UZTask { Id = Guid.NewGuid() }; UZTask t2 = new UZTask { Id = Guid.NewGuid() }; UZTask t3 = new UZTask { Id = Guid.NewGuid() }; UZTask t4 = new UZTask { Id = Guid.NewGuid() }; HashSet <UZTask> tasksSet1 = new HashSet <UZTask>(new UZTask.IdComparer()); tasksSet1.Add(t1); tasksSet1.Add(t2); tasksSet1.Add(t3); tasksSet1.Add(t4); HashSet <UZTask> tasksSet2 = new HashSet <UZTask>(new UZTask.IdComparer()); tasksSet2.Add(t2); tasksSet2.Add(t4); IEnumerable <UZTask> tasks3 = tasksSet1.Intersect(tasksSet2, new UZTask.IdComparer()); tasksSet1.IntersectWith(tasksSet2); Dictionary <UZTask, string> taskDictionary = new Dictionary <UZTask, string>(new UZTask.IdComparer()); taskDictionary.Add(new UZTask { Id = Guid.NewGuid() }, "hello world"); List <string> list = new List <string> { "hola", "adios" }; IImmutableList <string> immutableList = list.ToImmutableList(); }
public async Task CanAddDomainObjects() { WindsorContainer container = new WindsorContainer(); container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel)); container.Register ( // Repositories Component.For <IRepository <Guid, UZTask> >() .ImplementedBy <MemoryRepository <Guid, UZTask> >() .LifestyleTransient(), // Id generators Component.For <IIdGenerator <Guid> >() .ImplementedBy <GuidIdGenerator>(), // Specs Component.For <ISpecification <Guid, UZTask> >() .ImplementedBy <AddOrUpdateTaskSpec>() .LifestyleTransient() ); IRepository <Guid, UZTask> repo2 = container.Resolve <IRepository <Guid, UZTask> >(); List <ISpecification <Guid, UZTask> > specs = new List <ISpecification <Guid, UZTask> >(); specs.Add(new AddOrUpdateTaskSpec()); IRepository <Guid, UZTask> repo = new MemoryRepository <Guid, UZTask>(new GuidIdGenerator(), specs); UZTask testTask = new UZTask(); await repo.AddOrUpdateAsync(testTask); ISingleObjectResult <UZTask> gotTask = await repo.GetByIdAsync(testTask.Id); Assert.IsFalse(gotTask.Object.IsDirty); Assert.AreEqual(testTask, gotTask); }
public Task <IBasicResult> AddAsync(UZTask task) { throw new NotImplementedException(); }
public Task <IBasicResult> AddAsync(UZTask task) { return(UnitOfWork.Repository.AddOrUpdateAsync(task)); }