Exemple #1
0
        public async Task TestEnablePort_TracksUpdatePortsTask()
        {
            var tcs = new TaskCompletionSource <object>();

            _dataSourceMock.Setup(ds => ds.RefreshInstance(It.IsAny <Instance>()))
            .Returns(Task.FromResult(_defaultInstance));
            _dataSourceMock
            .Setup(
                ds => ds.UpdateInstancePorts(
                    It.IsAny <Instance>(),
                    It.IsAny <IList <FirewallPort> >(),
                    It.IsAny <IList <FirewallPort> >()))
            .Returns(
                new GceOperation(OperationType.ModifyingFirewall, "", "", "")
            {
                OperationTask = tcs.Task
            });

            var objectUnderTest = new AttachDebuggerFirewallPort(
                _defaultPortInfo,
                DefaultDescription,
                _defaultInstance,
                _dataSourceMock.ToLazy());
            Task task = objectUnderTest.EnablePort();

            Assert.IsFalse(task.IsCompleted);

            tcs.SetResult(null);

            await task;
        }
Exemple #2
0
        public async Task TestEnablePort_UpdatesInstancePortsFor()
        {
            _dataSourceMock.Setup(ds => ds.RefreshInstance(It.IsAny <Instance>()))
            .Returns(Task.FromResult(_expectedInstance));
            _dataSourceMock.Setup(
                ds => ds.UpdateInstancePorts(
                    _expectedInstance,
                    It.Is <IList <FirewallPort> >(
                        toEnable => toEnable.Single().Port == _expectedPortInfo.Port &&
                        toEnable.Single().Name == _expectedPortInfo.GetTag(ExpectedInstanceName)),
                    It.Is <IList <FirewallPort> >(l => l.Count == 0)))
            .Returns(new GceOperation(OperationType.ModifyingFirewall, "", "", "")
            {
                OperationTask = Task.CompletedTask
            })
            .Verifiable();

            var objectUnderTest = new AttachDebuggerFirewallPort(
                _expectedPortInfo,
                DefaultDescription,
                _defaultInstance,
                _dataSourceMock.ToLazy());
            await objectUnderTest.EnablePort();

            _dataSourceMock.Verify();
        }