示例#1
0
        public static IEndpointConfiguration <T, TId> CreateTestEndpointConfig <T, TId>(TypeConfiguration <T, TId> configuration)
            where TId : IEquatable <TId>
        {
            var endpoint = new InMemoryCrudDataEndpoint <T, TId>(configuration);

            return(new EndpointConfiguration <T, TId>(configuration, endpoint));
        }
 public void SetUpTest()
 {
     _dataSource = new InMemoryCrudDataEndpoint<LocalTestResource, int>(
         new TypeConfiguration<LocalTestResource, int>(
             ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1,
             -1));
     ConstrucTestSubject();
     _hasDispatched = false;
 }
示例#3
0
 public void SetUpTest()
 {
     _dataSource = new InMemoryCrudDataEndpoint <LocalTestResource, int>(
         new TypeConfiguration <LocalTestResource, int>(
             ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1,
             -1));
     ConstrucTestSubject();
     _hasDispatched = false;
 }
示例#4
0
 public void SetUpTest()
 {
     _dataSource = new InMemoryCrudDataEndpoint <LocalTestResource, int>(
         new TypeConfiguration <LocalTestResource, int>(
             ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1,
             -1));
     _observableUnderTest = new AttachedObservableCollection <LocalTestResource>(
         _dataSource
         , new LocalTestResourceIdComparer());
     _observableUnderTest.Where(ltr => ltr.Name.Contains("Ferry"));
 }
 public void SetUpTest()
 {
     _dataSource = new InMemoryCrudDataEndpoint<LocalTestResource, int>(
         new TypeConfiguration<LocalTestResource, int>(
             ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1,
             -1));
     _observableUnderTest = new AttachedObservableCollection<LocalTestResource>(
         _dataSource
         , new LocalTestResourceIdComparer());
     _observableUnderTest.Where(ltr => ltr.Name.Contains("Ferry"));
 }
        public void ShouldAddUpdatedItemIfNotInTheList()
        {
            _dataSource = new InMemoryCrudDataEndpoint<LocalTestResource, int>(
                new TypeConfiguration<LocalTestResource, int>(
                    ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1, -1));
            var addedItem = new LocalTestResource(1, 10) { Name = "TestResource" };
            _dataSource.Create(addedItem);
            ConstrucTestSubject();

            _dataSource.Update(addedItem);

            Assert.IsTrue(_observableUnderTest.Contains(addedItem));
        }
        public void SetUpTest()
        {
            _dateSource = new InMemoryCrudDataEndpoint<LocalTestResource, int>(
                new TypeConfiguration<LocalTestResource, int>(ltr => ltr.LocalId,
                0));
            _observableUnderTest = new AttachedObservableCollection<LocalTestResource>(
                _dateSource
                , new LocalTestResourceIdComparer());

            _smallest = new LocalTestResource(10) { Name = "Anthony" };
            _bigger = new LocalTestResource(1) { Name = "Bert" };
            _biggest = new LocalTestResource(2) { Name = "Zack" };
        }
示例#8
0
        public void ShouldAddUpdatedItemIfNotInTheList()
        {
            _dataSource = new InMemoryCrudDataEndpoint <LocalTestResource, int>(
                new TypeConfiguration <LocalTestResource, int>(
                    ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1, -1));
            var addedItem = new LocalTestResource(1, 10)
            {
                Name = "TestResource"
            };

            _dataSource.Create(addedItem);
            ConstrucTestSubject();

            _dataSource.Update(addedItem);

            Assert.IsTrue(_observableUnderTest.Contains(addedItem));
        }
示例#9
0
        public void SetUpTest()
        {
            var type1Config = new TypeConfiguration <LocalTestResource, int>(
                ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1,
                -1);

            LocalEndpoint = new InMemoryCrudDataEndpoint <LocalTestResource, int>(type1Config, TestData.LocalResults);
            var endpoint1Config = new EndpointConfiguration <LocalTestResource, int>(
                type1Config,
                LocalEndpoint);

            var type2Config = new TypeConfiguration <RemoteTestResource, int>(rtr => rtr.Id, 0);

            RemoteEndpoint = new InMemoryCrudDataEndpoint <RemoteTestResource, int>(type2Config, TestData.RemoteResults);
            var endpoint2Config = new EndpointConfiguration <RemoteTestResource, int>(
                type2Config,
                RemoteEndpoint);

            // This clearly requires a configuration API.
            ChannelConfig = new ChannelConfiguration <LocalTestResource, RemoteTestResource, int, ItemMatch <LocalTestResource, RemoteTestResource> >(endpoint1Config, endpoint2Config, new TestResourceTranslator());
            var itemsPreprocessor = new ItemMatcher <LocalTestResource, RemoteTestResource, int, ItemMatch <LocalTestResource, RemoteTestResource> >(ChannelConfig);

            ChannelConfig.ItemsPreprocessor = itemsPreprocessor.Match;

            var resolvers = new List <ISynchronizationResolver <ItemMatch <LocalTestResource, RemoteTestResource> > >
            {
                new SynchronizationResolver <ItemMatch <LocalTestResource, RemoteTestResource>, ChannelConfiguration <LocalTestResource, RemoteTestResource, int, ItemMatch <LocalTestResource, RemoteTestResource> > >(
                    ChannelConfig,
                    (item, cfg) => item.Result1 == null,
                    (item, cfg) =>
                {
                    var synchItem = item.Result1;
                    cfg.TypeTranslator.TranslateBackward(item.Result2, ref synchItem);

                    // Now the translate decides wether a new item has to be created, but the decision is there anyway because of the Create.
                    cfg.Type1EndpointConfiguration.Endpoint.Create(synchItem);
                    return(new SynchronizationResult(true));
                })
            };

            Plumber = new ItemMatchPipelinePlumber <LocalTestResource, RemoteTestResource, int>(ChannelConfig, resolvers, itemsPreprocessor.Match);
            ConstructTestSubject();
        }
示例#10
0
        public void SetUpTest()
        {
            var type1Config = new TypeConfiguration <LocalTestResource, int>(ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1);

            _localEndpoint = new InMemoryCrudDataEndpoint <LocalTestResource, int>(type1Config, TestData.LocalResults);
            var endpoint1Config = new EndpointConfiguration <LocalTestResource, int>(
                type1Config,
                _localEndpoint);

            var type2Config = new TypeConfiguration <RemoteTestResource, int>(rtr => rtr.Id);

            _remoteEndpoint = new InMemoryCrudDataEndpoint <RemoteTestResource, int>(type2Config, TestData.RemoteResults);
            var endpoint2Config = new EndpointConfiguration <RemoteTestResource, int>(
                type2Config,
                _remoteEndpoint);

            // This clearly requires a configuration API.
            var channelConfig     = new ChannelConfiguration <LocalTestResource, RemoteTestResource, int, ItemMatch <LocalTestResource, RemoteTestResource> >(endpoint1Config, endpoint2Config, new TestResourceTranslator());
            var itemsPreprocessor = new ItemMatcher <LocalTestResource, RemoteTestResource, int, ItemMatch <LocalTestResource, RemoteTestResource> >(channelConfig);

            channelConfig.ItemsPreprocessor = itemsPreprocessor.Match;
            channelConfig.AddSynchAction(new SynchronizationResolver <ItemMatch <LocalTestResource, RemoteTestResource>, ChannelConfiguration <LocalTestResource, RemoteTestResource, int, ItemMatch <LocalTestResource, RemoteTestResource> > >(
                                             channelConfig,
                                             (item, cfg) =>
            {
                return(item.Result1 == null);
            },
                                             (item, cfg) =>
            {
                var synchItem = item.Result1;
                cfg.TypeTranslator.TranslateBackward(item.Result2, ref synchItem);
                // Now the translate decides wether a new item has to be created, but the decision is there anyway because of the Create.
                cfg.Type1EndpointConfiguration.Endpoint.Create(synchItem);
                return(new SynchronizationResult(true));
            }
                                             ));

            //var t2epConfig = new EndpointConfiguration()
            _channelUnderTest = new OneWayPullChannel <LocalTestResource, RemoteTestResource, int, ItemMatch <LocalTestResource, RemoteTestResource> >(
                channelConfig,
                () => Task.FromResult(_localEndpoint.ReadAll().AsEnumerable()),
                () => Task.FromResult(_remoteEndpoint.ReadAll().AsEnumerable()));
        }
        public void SetUpTest()
        {
            var type1Config = new TypeConfiguration<LocalTestResource, int>(
                ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1,
                -1);
            LocalEndpoint = new InMemoryCrudDataEndpoint<LocalTestResource, int>(type1Config, TestData.LocalResults);
            var endpoint1Config = new EndpointConfiguration<LocalTestResource, int>(
                type1Config,
                LocalEndpoint);

            var type2Config = new TypeConfiguration<RemoteTestResource, int>(rtr => rtr.Id, 0);
            RemoteEndpoint = new InMemoryCrudDataEndpoint<RemoteTestResource, int>(type2Config, TestData.RemoteResults);
            var endpoint2Config = new EndpointConfiguration<RemoteTestResource, int>(
                type2Config,
                RemoteEndpoint);

            // This clearly requires a configuration API.
            ChannelConfig = new ChannelConfiguration<LocalTestResource, RemoteTestResource, int, ItemMatch<LocalTestResource, RemoteTestResource>>(endpoint1Config, endpoint2Config, new TestResourceTranslator());
            var itemsPreprocessor = new ItemMatcher<LocalTestResource, RemoteTestResource, int, ItemMatch<LocalTestResource, RemoteTestResource>>(ChannelConfig);

            ChannelConfig.ItemsPreprocessor = itemsPreprocessor.Match;

            var resolvers = new List<ISynchronizationResolver<ItemMatch<LocalTestResource, RemoteTestResource>>>
            {
                new SynchronizationResolver<ItemMatch<LocalTestResource,RemoteTestResource>, ChannelConfiguration<LocalTestResource, RemoteTestResource, int, ItemMatch<LocalTestResource, RemoteTestResource>>>(
                ChannelConfig,
                (item, cfg) => item.Result1 == null,
                (item, cfg) =>
                {
                    var synchItem = item.Result1;
                    cfg.TypeTranslator.TranslateBackward(item.Result2, ref synchItem);

                    // Now the translate decides wether a new item has to be created, but the decision is there anyway because of the Create.
                    cfg.Type1EndpointConfiguration.Endpoint.Create(synchItem);
                    return new SynchronizationResult(true);
                })
            };
            Plumber = new ItemMatchPipelinePlumber<LocalTestResource, RemoteTestResource, int>(ChannelConfig, resolvers, itemsPreprocessor.Match);
            ConstructTestSubject();
        }
示例#12
0
        public void SetUpTest()
        {
            var type1Config = new TypeConfiguration<LocalTestResource, int>(ltr => ltr.CorrelationId.HasValue ? ltr.CorrelationId.Value : -1);
            _localEndpoint = new InMemoryCrudDataEndpoint<LocalTestResource, int>(type1Config, TestData.LocalResults);
            var endpoint1Config = new EndpointConfiguration<LocalTestResource, int>(
                type1Config,
                _localEndpoint);

            var type2Config = new TypeConfiguration<RemoteTestResource, int>(rtr => rtr.Id);
            _remoteEndpoint = new InMemoryCrudDataEndpoint<RemoteTestResource, int>(type2Config, TestData.RemoteResults);
            var endpoint2Config = new EndpointConfiguration<RemoteTestResource, int>(
                type2Config,
                _remoteEndpoint);

            // This clearly requires a configuration API.
            var channelConfig = new ChannelConfiguration<LocalTestResource, RemoteTestResource, int, ItemMatch<LocalTestResource, RemoteTestResource>>(endpoint1Config, endpoint2Config, new TestResourceTranslator());
            var itemsPreprocessor = new ItemMatcher<LocalTestResource, RemoteTestResource, int, ItemMatch<LocalTestResource, RemoteTestResource>>(channelConfig);
            channelConfig.ItemsPreprocessor = itemsPreprocessor.Match;
            channelConfig.AddSynchAction(new SynchronizationResolver<ItemMatch<LocalTestResource,RemoteTestResource>, ChannelConfiguration<LocalTestResource, RemoteTestResource, int, ItemMatch<LocalTestResource, RemoteTestResource>>>(
                channelConfig,
                (item, cfg) =>
                {
                    return item.Result1 == null;
                },
                (item, cfg) =>
                {
                    var synchItem = item.Result1;
                    cfg.TypeTranslator.TranslateBackward(item.Result2, ref synchItem);
                    // Now the translate decides wether a new item has to be created, but the decision is there anyway because of the Create.
                    cfg.Type1EndpointConfiguration.Endpoint.Create(synchItem);
                    return new SynchronizationResult(true);
                }
            ));

            //var t2epConfig = new EndpointConfiguration()
            _channelUnderTest = new OneWayPullChannel<LocalTestResource, RemoteTestResource, int, ItemMatch<LocalTestResource, RemoteTestResource>>(
                channelConfig,
                () => Task.FromResult(_localEndpoint.ReadAll().AsEnumerable()),
                () => Task.FromResult(_remoteEndpoint.ReadAll().AsEnumerable()));
        }
        public void SetUpTest()
        {
            _dateSource = new InMemoryCrudDataEndpoint <LocalTestResource, int>(
                new TypeConfiguration <LocalTestResource, int>(ltr => ltr.LocalId,
                                                               0));
            _observableUnderTest = new AttachedObservableCollection <LocalTestResource>(
                _dateSource
                , new LocalTestResourceIdComparer());

            _smallest = new LocalTestResource(10)
            {
                Name = "Anthony"
            };
            _bigger = new LocalTestResource(1)
            {
                Name = "Bert"
            };
            _biggest = new LocalTestResource(2)
            {
                Name = "Zack"
            };
        }
示例#14
0
 public void SetUpTest()
 {
     _channelConfig = Setup.TestChannelConfig();
     _localEndpoint = _channelConfig.Type1EndpointConfiguration.Endpoint as InMemoryCrudDataEndpoint<LocalTestResource, int>;
     _remoteEndpoint = _channelConfig.Type2EndpointConfiguration.Endpoint as InMemoryCrudDataEndpoint<RemoteTestResource, int>;
 }
示例#15
0
 public void SetUpTest()
 {
     _channelConfig  = Setup.TestChannelConfig();
     _localEndpoint  = _channelConfig.Type1EndpointConfiguration.Endpoint as InMemoryCrudDataEndpoint <LocalTestResource, int>;
     _remoteEndpoint = _channelConfig.Type2EndpointConfiguration.Endpoint as InMemoryCrudDataEndpoint <RemoteTestResource, int>;
 }