public void EmptyTest()
        {
            SetupStore("Source", 0);
            FileSystemWorkItemEndpoint e = CreateEndpoint("Source");

            Assert.AreEqual(0, e.Count);
        }
        public void ConfiguredTest()
        {
            SetupStore(@".\Store\Source\", 10);
            FileSystemWorkItemEndpoint e = CreateAndConfigureInMemoryWorkItemEndpoint(EndpointDirection.Source, @".\Store\Source\");

            Assert.AreEqual(10, e.Count);
        }
        public void EmptyTest()
        {
            SetupStore(EndpointDirection.Source, 0);
            FileSystemWorkItemEndpoint e = CreateEndpoint(EndpointDirection.Source);

            Assert.AreEqual(0, e.Count);
        }
        public void ConfiguredTest()
        {
            SetupStore("Source", 10);
            FileSystemWorkItemEndpoint e = CreateEndpoint("Source");

            Assert.AreEqual(10, e.Count);
        }
        public void ConfiguredTest()
        {
            SetupStore(EndpointDirection.Source, 10);
            FileSystemWorkItemEndpoint e = CreateEndpoint(EndpointDirection.Source);

            Assert.AreEqual(10, e.Count);
        }
        private static FileSystemWorkItemEndpoint CreateAndConfigureInMemoryWorkItemEndpoint(EndpointDirection direction, string queryString)
        {
            FileSystemWorkItemEndpoint e     = CreateInMemoryWorkItemEndpoint(EndpointDirection.Source);
            FileSystemWorkItemQuery    query = new FileSystemWorkItemQuery();

            query.Configure(null, queryString, null);
            e.Configure(query, null);
            return(e);
        }
        private static FileSystemWorkItemEndpoint CreateInMemoryWorkItemEndpoint(EndpointDirection direction)
        {
            var options = Options.Create <FileSystemWorkItemEndpointOptions>(new FileSystemWorkItemEndpointOptions()
            {
                Direction = direction
            });
            FileSystemWorkItemEndpoint e = new FileSystemWorkItemEndpoint(options);

            return(e);
        }
        public void FilterHalfTest()
        {
            SetupStore(@".\Store\Source\", 20);
            SetupStore(@".\Store\target\", 10);
            FileSystemWorkItemEndpoint e1 = CreateAndConfigureInMemoryWorkItemEndpoint(EndpointDirection.Source, @".\Store\Source\");
            FileSystemWorkItemEndpoint e2 = CreateAndConfigureInMemoryWorkItemEndpoint(EndpointDirection.Source, @".\Store\target\");

            e1.Filter(e2.WorkItems);
            Assert.AreEqual(10, e1.Count);
        }
        public void FilterHalfTest()
        {
            SetupStore(EndpointDirection.Source, 20);
            FileSystemWorkItemEndpoint e1 = CreateEndpoint(EndpointDirection.Source);

            SetupStore(EndpointDirection.Target, 10);
            FileSystemWorkItemEndpoint e2 = CreateEndpoint(EndpointDirection.Target);

            e1.Filter(e2.GetWorkItems());
            Assert.AreEqual(10, e1.Count);
        }
        private FileSystemWorkItemEndpoint CreateEndpoint(EndpointDirection direction)
        {
            var options = new FileSystemWorkItemEndpointOptions()
            {
                Direction = direction, FileStore = string.Format(@".\Store\{0}\", direction.ToString())
            };
            FileSystemWorkItemEndpoint e = Services.GetRequiredService <FileSystemWorkItemEndpoint>();

            e.Configure(options);
            return(e);
        }
        public void FilterHalfTest()
        {
            SetupStore("Source", 20);
            FileSystemWorkItemEndpoint e1 = CreateEndpoint("Source");

            SetupStore("Target", 10);
            FileSystemWorkItemEndpoint e2 = CreateEndpoint("Target");

            e1.Filter(e2.GetWorkItems());
            Assert.AreEqual(10, e1.Count);
        }
        public void PersistWorkItemExistsTest()
        {
            SetupStore(@".\Store\Source\", 20);
            SetupStore(@".\Store\target\", 10);
            FileSystemWorkItemEndpoint e1 = CreateAndConfigureInMemoryWorkItemEndpoint(EndpointDirection.Source, @".\Store\Source\");
            FileSystemWorkItemEndpoint e2 = CreateAndConfigureInMemoryWorkItemEndpoint(EndpointDirection.Source, @".\Store\target\");

            foreach (WorkItemData item in e1.WorkItems)
            {
                e2.PersistWorkItem(item);
            }
            Assert.AreEqual(20, e2.Count);
        }
        public void PersistWorkItemExistsTest()
        {
            SetupStore(EndpointDirection.Source, 20);
            FileSystemWorkItemEndpoint e1 = CreateEndpoint(EndpointDirection.Source);

            SetupStore(EndpointDirection.Target, 10);
            FileSystemWorkItemEndpoint e2 = CreateEndpoint(EndpointDirection.Target);

            foreach (WorkItemData item in e1.GetWorkItems())
            {
                e2.PersistWorkItem(item);
            }
            Assert.AreEqual(20, e2.Count);
        }
        public void PersistWorkItemWithFilterTest()
        {
            SetupStore("Source", 20);
            FileSystemWorkItemEndpoint e1 = CreateEndpoint("Source");

            SetupStore("Target", 10);
            FileSystemWorkItemEndpoint e2 = CreateEndpoint("Target");

            e1.Filter(e2.GetWorkItems());
            Assert.AreEqual(10, e1.Count);
            foreach (WorkItemData item in e1.GetWorkItems())
            {
                e2.PersistWorkItem(item);
            }
            Assert.AreEqual(20, e2.Count);
        }
        public void SetupStore(string path, int count)
        {
            if (System.IO.Directory.Exists(path))
            {
                System.IO.Directory.Delete(path, true);
            }
            FileSystemWorkItemEndpoint e = CreateAndConfigureInMemoryWorkItemEndpoint(EndpointDirection.Source, path);

            for (int i = 0; i < count; i++)
            {
                e.PersistWorkItem(new WorkItemData()
                {
                    Id = i.ToString(), Title = string.Format("Title {0}", i)
                });
            }
        }
        public void SetupStore(EndpointDirection direction, int count)
        {
            string path = string.Format(@".\Store\{0}\", direction.ToString());

            if (System.IO.Directory.Exists(path))
            {
                System.IO.Directory.Delete(path, true);
            }
            FileSystemWorkItemEndpoint e = CreateEndpoint(direction);

            for (int i = 0; i < count; i++)
            {
                e.PersistWorkItem(new WorkItemData()
                {
                    Id = i.ToString()
                });
            }
        }
        public void EmptyTest()
        {
            FileSystemWorkItemEndpoint e = CreateInMemoryWorkItemEndpoint(EndpointDirection.Source);

            Assert.AreEqual(0, e.Count);
        }