public void Copy_EmptyModel_To_Other_EmptyModel_WithoutForce() { //Arrange var fromKey = "key1"; var toKey = "key2"; var sourceBlipAIClient = Substitute.For <IBlipAIClient>(); sourceBlipAIClient.GetAllIntentsAsync(Arg.Any <bool>()).Returns(Task.FromResult <List <Intention> >(null)); sourceBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult <List <Entity> >(null)); var targetBlipAIClient = Substitute.For <IBlipAIClient>(); targetBlipAIClient.GetAllIntentsAsync(Arg.Any <bool>()).Returns(Task.FromResult <List <Intention> >(null)); targetBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult <List <Entity> >(null)); var blipAIClientFactory = Substitute.For <IBlipClientFactory>(); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(fromKey))).Returns(sourceBlipAIClient); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(toKey))).Returns(targetBlipAIClient); var logger = Substitute.For <IInternalLogger>(); var handler = new CopyHandler(blipAIClientFactory, logger); handler.FromAuthorization = new MyNamedParameter <string> { Value = fromKey }; handler.ToAuthorization = new MyNamedParameter <string> { Value = toKey }; handler.From = new MyNamedParameter <string>(); handler.To = new MyNamedParameter <string>(); handler.Verbose = new MySwitch { IsSet = false }; handler.Force = new MySwitch { IsSet = false }; handler.Contents = new MyNamedParameter <List <BucketNamespace> > { Value = new List <BucketNamespace> { BucketNamespace.AIModel } }; //Act var result = handler.RunAsync(null).Result; //Assert Assert.AreEqual(0, result); }
public void Scenario1Test() { //Arrange var fromKey = "key1"; var toKey = "key2"; var sourceBlipAIClient = Substitute.For <IBlipAIClient>(); sourceBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult <List <Entity> >(null)); sourceBlipAIClient.GetAllIntents(Arg.Any <bool>()).Returns(Task.FromResult <List <Intention> >(null)); var targetBlipAIClient = Substitute.For <IBlipAIClient>(); var blipAIClientFactory = Substitute.For <IBlipClientFactory>(); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(fromKey))).Returns(sourceBlipAIClient); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(toKey))).Returns(targetBlipAIClient); var handler = new CopyHandler(blipAIClientFactory); handler.FromAuthorization = new MyNamedParameter <string> { Value = fromKey }; handler.ToAuthorization = new MyNamedParameter <string> { Value = toKey }; handler.From = new MyNamedParameter <string>(); handler.To = new MyNamedParameter <string>(); handler.Verbose = new MySwitch { IsSet = false }; handler.Force = new MySwitch { IsSet = false }; handler.Contents = new MyNamedParameter <List <BucketNamespace> > { Value = new List <BucketNamespace> { BucketNamespace.AIModel } }; //Act handler.RunAsync(null).Wait(); //Assert }
public void Copy_EmptyModel_To_Model_WithoutForce(int numIntents, int numEntities) { //Arrange var fromKey = "key1"; var toKey = "key2"; var intents = new List <Intention>(); for (int i = 0; i < numIntents; i++) { intents.Add(new Intention { Id = $"{i}", Name = $"Name{i}" }); } var entities = new List <Entity>(); for (int i = 0; i < numEntities; i++) { entities.Add(new Entity { Id = $"{i}", Name = $"Name{i}" }); } var sourceBlipAIClient = Substitute.For <IBlipAIClient>(); sourceBlipAIClient.GetAllIntentsAsync(Arg.Any <bool>()).Returns(Task.FromResult <List <Intention> >(null)); sourceBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult <List <Entity> >(null)); var targetBlipAIClient = Substitute.For <IBlipAIClient>(); targetBlipAIClient.GetAllIntentsAsync(Arg.Any <bool>()).Returns(Task.FromResult(intents)); targetBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult(entities)); var blipAIClientFactory = Substitute.For <IBlipClientFactory>(); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(fromKey))).Returns(sourceBlipAIClient); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(toKey))).Returns(targetBlipAIClient); var logger = Substitute.For <IInternalLogger>(); var handler = new CopyHandler(blipAIClientFactory, logger); handler.FromAuthorization = new MyNamedParameter <string> { Value = fromKey }; handler.ToAuthorization = new MyNamedParameter <string> { Value = toKey }; handler.Verbose = new MySwitch { IsSet = false }; handler.Force = new MySwitch { IsSet = false }; handler.Contents = new MyNamedParameter <List <BucketNamespace> > { Value = new List <BucketNamespace> { BucketNamespace.AIModel } }; //Act var result = handler.RunAsync(null).Result; //Assert Assert.AreEqual(0, result); targetBlipAIClient.DidNotReceive().AddEntity(Arg.Any <Entity>()); targetBlipAIClient.DidNotReceive().AddIntent(Arg.Any <string>()); targetBlipAIClient.DidNotReceive().DeleteIntent(Arg.Any <string>()); targetBlipAIClient.DidNotReceive().DeleteEntity(Arg.Any <string>()); }