Ejemplo n.º 1
0
        public void WhenResolvingExtensionAndNoMatches_ThenReturnsNull()
        {
            var container = new Mock <IAutomationExtension>();

            container.Setup(c => c.Owner.AutomationExtensions).Returns(new List <IAutomationExtension>());
            container.Setup(c => c.Owner.Info.AutomationSettings).Returns(new List <IAutomationSettingsInfo>());

            var extension = AutomationExtensionExtensions.ResolveAutomationReference <TestAutomation>(container.Object, Guid.Empty);

            Assert.Null(extension);
        }
Ejemplo n.º 2
0
        public void WhenResolvingExtension_ThenReturnsMatchingByTypeAndIdAndName()
        {
            var extensions = new List <IAutomationExtension>
            {
                Mocks.Of <IAutomationExtension>().First(x => x.Name == "Foo"),
                new TestAutomation {
                    Name = "Foo"
                },
                new TestAutomation {
                    Name = "Bar"
                },
            };

            var extensionGuid = Guid.NewGuid();

            var settings = new List <IAutomationSettingsInfo>
            {
                Mocks.Of <IAutomationSettingsInfo>().First(x => x.Id == Guid.Empty && x.Name == "Foo"),
                Mocks.Of <IAutomationSettingsInfo>().First(x => x.Id == extensionGuid && x.Name == "Bar"),
            };

            Mock.Get(settings[0]).Setup(i => i.As <IAutomationSettings>()).Returns(
                Mocks.Of <IAutomationSettings>().First(x => x.Id == Guid.Empty && x.Name == "Foo"));

            Mock.Get(settings[1]).Setup(i => i.As <IAutomationSettings>()).Returns(
                Mocks.Of <IAutomationSettings>().First(x => x.Id == extensionGuid && x.Name == "Bar"));

            var container = new Mock <IAutomationExtension>();

            container.Setup(c => c.Owner.AutomationExtensions).Returns(extensions);
            container.Setup(c => c.Owner.Info.AutomationSettings).Returns(settings);

            var extension = AutomationExtensionExtensions.ResolveAutomationReference <ITestAutomation>(container.Object, extensionGuid);

            Assert.NotNull(extension);
        }
Ejemplo n.º 3
0
 public void WhenResolvingExtensionWithNullContainer_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           AutomationExtensionExtensions.ResolveAutomationReference <TestAutomation>(null, Guid.Empty));
 }