Ejemplo n.º 1
0
 public void DistributeMessages_OneChannel_Ok()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormaplocal2local.xml", _componentResolver);
     ChangePublisher changePublisher = InitiateLocalPublisher();
     changePublisher.PublishPackage();
     MockAllTheSubscribers(distributor.AvailableChannels,changePublisher.PublishedPackageNotDistributed[0]);
     distributor.DistributeMessages();
     Assert.AreEqual(0, changePublisher.PublishedPackageNotDistributed.Count);
 }
Ejemplo n.º 2
0
 public void ChannelGoesDownPermanentlyOnlyOneChanelLocal_Ok()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormap2.xml", _componentResolver);
     Assert.IsNotNull(distributor.AvailableChannels);
     Assert.AreEqual(1, distributor.AvailableChannels.Count(c => c.Status == Status.OfflineTemporary && c.NoOfFailedAttempts == 1));
     distributor.DistributeMessages();
     Assert.AreEqual(1, distributor.AvailableChannels.Count(c => c.Status == Status.OfflineTemporary && c.NoOfFailedAttempts == 2));
     distributor.DistributeMessages();
     Assert.AreEqual(1, distributor.AvailableChannels.Count(c => c.Status == Status.OfflineTemporary && c.NoOfFailedAttempts == 3));
     distributor.DistributeMessages();
     Assert.AreEqual(1, distributor.AvailableChannels.Count(c => c.Status == Status.OfflinePermanent && c.NoOfFailedAttempts == 3));
 }
Ejemplo n.º 3
0
 public void BasicLoadingTestWithOneLocalChannelOneRemoteChannelAndOneMixedChannel_Ok()
 {
     Distributor distributor=new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormap.xml",_componentResolver);
     Assert.IsNotNull(distributor.AvailableChannels);
     Assert.AreEqual(1,
                     distributor.AvailableChannels.Count(
                         c =>
                         c.Status == Status.Ok && c.PublisherInfo.Port==0 &&
                         c.SubscriberInfo.Port==0));
     Assert.AreEqual(1,
                     distributor.AvailableChannels.Count(
                         c =>
                         c.Status == Status.Ok && c.PublisherInfo.Port==8765 &&
                         c.SubscriberInfo.Port==8766));
     Assert.AreEqual(1,
                     distributor.AvailableChannels.Count(
                         c =>
                         c.Status == Status.Ok && c.PublisherInfo.Port==0 &&
                         c.SubscriberInfo.Port == 8766));
 }
Ejemplo n.º 4
0
        public void DsitributeMessages_OnepublisherThreeChannels_OneNotPresentOneFailing()
        {
            Distributor distributor = new Distributor();
            distributor.InitiateDistributionMap(@"Data\distributormaplocal2localandremoteNP.xml", _componentResolver);

            ChangePublisher changePublisher = InitiateLocalPublisher();

            distributor.DistributeMessages();
            Assert.AreEqual(1, changePublisher.PublishedPackageNotDistributed.Count);
            Assert.AreEqual(2, changePublisher.PublishedPackageNotDistributed[0].ChangePushItems.Count);
        }
Ejemplo n.º 5
0
 public void LoadDistributorWrongMapFile()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\nonmap.xml", _componentResolver);
 }
Ejemplo n.º 6
0
 public void LoadDistributorNoRegisteredPublishers()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormap.xml", new ComponentResolver());
     Assert.AreEqual(0, distributor.AvailableChannels.Count(c => c.Status == Status.Ok));
 }
Ejemplo n.º 7
0
 public void LoadDistributorNoResolver()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormap.xml", null);
 }
Ejemplo n.º 8
0
 public void LoadDistributorNoMapFile()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(null, _componentResolver);
 }
Ejemplo n.º 9
0
 public void ListAllComponents_AndRegisterMessages_Ok()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormap5.xml", _componentResolver);
     ChangePublisher changePublisher = (ChangePublisher)distributor.AvailableChannels
     .FirstOrDefault(c => c.PublisherInfo.Port==0).Publisher;
     var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("root folder");
     changePublisher.Initialize("root folder",mockItemDiscoverer);
     changePublisher.QueueInsert(@"root folder\Item One");
     changePublisher.QueueInsert(@"root folder\ItemTwo");
     changePublisher.PublishPackage();
     MockAllTheSubscribers(distributor.AvailableChannels, changePublisher.PublishedPackageNotDistributed[0]);
     distributor.DistributeMessages();
     var compo = distributor.ListAvailableChannels();
     Assert.IsNotNull(compo);
     Assert.AreEqual(1, compo.Channels.Count);
     Assert.IsNotNull(compo.Channels[0].SubscriberInfo);
     Assert.AreEqual(State.Done, compo.Channels[0].PublisherInfo.CurrentPackage.State);
     Assert.AreEqual(1, compo.Channels[0].PublisherInfo.CurrentPackage.PackageMessages.Count(m => m.AbsolutePath == @"root folder\Item One"));
     Assert.AreEqual(2, compo.Channels[0].PublisherInfo.CurrentPackage.PackageMessages.Count(m => m.OperationType==OperationType.Insert));
     Assert.AreEqual(State.Done, compo.Channels[0].SubscriberInfo.CurrentPackage.State);
 }
Ejemplo n.º 10
0
 public void ListAllAvailableChannels_Ok()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormap.xml", _componentResolver);
     var compo = distributor.ListAvailableChannels();
     Assert.IsNotNull(compo);
     Assert.AreEqual(3,compo.Channels.Count);
     Assert.IsNotNull(compo.Channels[0].SubscriberInfo);
     Assert.IsNotNull(compo.Channels[1].SubscriberInfo);
     foreach(var c1 in compo.Channels)
     {
         Assert.AreEqual(Status.Ok,c1.Status);
     }
 }
Ejemplo n.º 11
0
 public void InitiateDistributionMap_OneRemoteSubscriber_notWorking()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormap4.xml", _componentResolver);
     Assert.IsNotNull(distributor.AvailableChannels);
     Assert.AreEqual(1, distributor.AvailableChannels.Count(c => c.Status == Status.OfflineTemporary && c.NoOfFailedAttempts == 1));
 }
Ejemplo n.º 12
0
 public void GetCurrentMap_Ok()
 {
     Distributor distributor = new Distributor();
     distributor.InitiateDistributionMap(@"Data\distributormap.xml", _componentResolver);
     var distributorMap = distributor.GetCurrentMap();
     Assert.IsNotNull(distributorMap);
     Assert.IsNotNull(distributorMap);
     Assert.AreEqual(3,distributorMap.Count());
 }