Esempio n. 1
0
        public async Task TestIsPortEnabled_ShortCircutFalse()
        {
            _expectedInstance.Tags = new Tags {
                Items = new List <string>()
            };
            var objectUnderTests = new AttachDebuggerFirewallPort(
                _expectedPortInfo,
                DefaultDescription,
                _expectedInstance,
                _dataSourceMock.ToLazy());

            bool result = await objectUnderTests.IsPortEnabled();

            Assert.IsFalse(result);
        }
Esempio n. 2
0
        public async Task TestIsPortEnabled_False()
        {
            _dataSourceMock.Setup(ds => ds.GetFirewallListAsync())
            .Returns(Task.FromResult <IList <Firewall> >(new List <Firewall>()));
            _expectedInstance.Tags =
                new Tags {
                Items = new List <string> {
                    _expectedPortInfo.GetTag(ExpectedInstanceName)
                }
            };
            var objectUnderTests = new AttachDebuggerFirewallPort(
                _expectedPortInfo,
                DefaultDescription,
                _expectedInstance,
                _dataSourceMock.ToLazy());

            bool result = await objectUnderTests.IsPortEnabled();

            Assert.IsFalse(result);
        }
Esempio n. 3
0
        public async Task TestIsPortEnabled_True()
        {
            string targetTag = _expectedPortInfo.GetTag(ExpectedInstanceName);

            _dataSourceMock.Setup(ds => ds.GetFirewallListAsync())
            .Returns(
                Task.FromResult <IList <Firewall> >(
                    new List <Firewall>
            {
                new Firewall
                {
                    TargetTags = new List <string> {
                        targetTag
                    },
                    Allowed = new List <Firewall.AllowedData>
                    {
                        new Firewall.AllowedData
                        {
                            IPProtocol = "tcp",
                            Ports      = new List <string> {
                                _expectedPortInfo.Port.ToString()
                            }
                        }
                    }
                }
            }));
            var objectUnderTests = new AttachDebuggerFirewallPort(
                _expectedPortInfo,
                DefaultDescription,
                PortTestHelpers.GetInstanceWithEnabledPort(_expectedPortInfo, ExpectedInstanceName),
                _dataSourceMock.ToLazy());

            bool result = await objectUnderTests.IsPortEnabled();

            Assert.IsTrue(result);
        }