Пример #1
0
        public void Trigger_DoesTransition()
        {
            var w      = new TestState("w");
            var j      = new TestState("j");
            var signal = new TestSignal()
            {
                Value = true
            };
            var signal2 = new TestSignal()
            {
                Value = false
            };

            w.Add(signal, () => j);
            j.Add(signal2, () => w);

            var n = w.Update(0.0f);

            Assert.AreEqual(j, n.Peek());
            Assert.AreEqual(w.enterCalled, 1);
            Assert.AreEqual(w.exitCalled, 1);
            Assert.AreEqual(signal.ResetCalled, 1);
            Assert.AreEqual(signal.UpdateCalled, 1);
            Assert.AreEqual(signal2.UpdateCalled, 0);

            var n2 = n.Peek().Update(0.0f);

            Assert.AreEqual(n.Peek(), n2.Peek());
            Assert.AreEqual(j.enterCalled, 1);
            Assert.AreEqual(j.exitCalled, 0);
            Assert.AreEqual(signal2.ResetCalled, 1);
            Assert.AreEqual(signal.ResetCalled, 1);
            Assert.AreEqual(signal.UpdateCalled, 1);
            Assert.AreEqual(signal2.UpdateCalled, 1);
        }
Пример #2
0
        public void MirandaGetCommandTest()
        {
            TestSignal testSignal = context.Get <TestSignal>();

            Assert.NotNull(testSignal);
            testSignal.Dispatch();
            Assert.Fail();
        }
Пример #3
0
        public void SetUp()
        {
            testCommand = Substitute.For <CommandTest>();
            testBinder  = Substitute.For <IBinder>();

            testSignal          = new TestSignal();
            testSignal.injector = testBinder;
        }
Пример #4
0
        public void SetUp()
        {
            testCommand = Substitute.For<CommandTest>();
            testBinder = Substitute.For<IBinder>();

            testSignal = new TestSignal();
            testSignal.injector = testBinder;
        }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        Application.RegisterLogCallback(HandleLog);
        Context context = Miranda.Init(new ParentContext(), new OtherContext());

        ExceptionSignal eS = context.Get <ExceptionSignal>();

        eS.AddOnce((x) => {
            Debug.Log(x[0]);
        });

        IObjectInject tA = context.Get <IObjectInject>();

        tA.PrintAFew();

        Debug.Log("+++++++++++++++++++++++++");

        IObjectInject tAA = context.Get <IObjectInject>();

        tAA.PrintAFew();

        Debug.Log("+++++++++++++++++++++++++");

        tAA.ChangeName("TESTINGOFSINGLETON");

        tA.PrintAFew();

        TestSignal testSignal = context.Get <TestSignal>();

        testSignal.AddOnce((x) => {
            foreach (object o in x)
            {
                Debug.Log(o);
            }
        });

        testSignal.Dispatch("A", "b", "C");

        TestSignal anotherSignal = context.Get <TestSignal>();

        anotherSignal.Dispatch();
    }
Пример #6
0
        public void Trigger_DoesTransitionX()
        {
            var w      = new TestState("w");
            var j      = new TestState("j");
            var signal = new TestSignal()
            {
                Value = true
            };
            var signal2 = new TestSignal()
            {
                Value = false
            };

            w.AddPush(signal, () => j);

            var n  = w.Update(0.0f);
            var n2 = n.Peek().Update(0.0f);

            Assert.AreEqual(2, n.Count);
        }
Пример #7
0
 void OnRevTestSignal(TestSignal signal)
 {
     Debug.Log(signal.Msg);
 }
Пример #8
0
        public void MirandaGetSignalTest()
        {
            TestSignal testSignal = context.Get <TestSignal>();

            Assert.NotNull(testSignal);
        }
Пример #9
0
 public void TearDown()
 {
     testSignal  = null;
     testBinder  = null;
     testCommand = null;
 }
Пример #10
0
 public void TearDown()
 {
     testSignal = null;
     testBinder = null;
     testCommand = null;
 }
        private void TestInitialize(ResourceType requestResourceType, ResourceType signalResourceType)
        {
            this.tracerMock = new Mock <ITracer>();

            ResourceIdentifier resourceId;

            switch (requestResourceType)
            {
            case ResourceType.Subscription:
                resourceId = new ResourceIdentifier(requestResourceType, "subscriptionId", string.Empty, string.Empty);
                break;

            case ResourceType.ResourceGroup:
                resourceId = new ResourceIdentifier(requestResourceType, "subscriptionId", "resourceGroup", string.Empty);
                break;

            default:
                resourceId = new ResourceIdentifier(requestResourceType, "subscriptionId", "resourceGroup", "resourceName");
                break;
            }

            this.resourceIds = new List <string>()
            {
                resourceId.ToResourceId()
            };
            this.request = new SmartSignalRequest(this.resourceIds, "1", DateTime.UtcNow.AddDays(-1), TimeSpan.FromDays(1), new SmartSignalSettings());

            var smartSignalManifest = new SmartSignalManifest("1", "Test signal", "Test signal description", Version.Parse("1.0"), "assembly", "class", new List <ResourceType>()
            {
                signalResourceType
            }, new List <int> {
                60
            });

            this.smartSignalPackage = new SmartSignalPackage(smartSignalManifest, new Dictionary <string, byte[]> {
                ["TestSignalLibrary"] = new byte[0]
            });

            this.smartSignalsRepositoryMock = new Mock <ISmartSignalRepository>();
            this.smartSignalsRepositoryMock
            .Setup(x => x.ReadSignalPackageAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => this.smartSignalPackage);

            this.analysisServicesFactoryMock = new Mock <IAnalysisServicesFactory>();

            this.signal = new TestSignal {
                ExpectedResourceType = signalResourceType
            };

            this.smartSignalLoaderMock = new Mock <ISmartSignalLoader>();
            this.smartSignalLoaderMock
            .Setup(x => x.LoadSignal(this.smartSignalPackage))
            .Returns(this.signal);

            this.azureResourceManagerClientMock = new Mock <IAzureResourceManagerClient>();
            this.azureResourceManagerClientMock
            .Setup(x => x.GetAllResourceGroupsInSubscriptionAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync((string subscriptionId, CancellationToken cancellationToken) => new List <ResourceIdentifier>()
            {
                new ResourceIdentifier(ResourceType.ResourceGroup, subscriptionId, "resourceGroupName", string.Empty)
            });
            this.azureResourceManagerClientMock
            .Setup(x => x.GetAllResourcesInSubscriptionAsync(It.IsAny <string>(), It.IsAny <IEnumerable <ResourceType> >(), It.IsAny <CancellationToken>()))
            .ReturnsAsync((string subscriptionId, IEnumerable <ResourceType> resourceTypes, CancellationToken cancellationToken) => new List <ResourceIdentifier>()
            {
                new ResourceIdentifier(ResourceType.VirtualMachine, subscriptionId, "resourceGroupName", "resourceName")
            });
            this.azureResourceManagerClientMock
            .Setup(x => x.GetAllResourcesInResourceGroupAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <IEnumerable <ResourceType> >(), It.IsAny <CancellationToken>()))
            .ReturnsAsync((string subscriptionId, string resourceGroupName, IEnumerable <ResourceType> resourceTypes, CancellationToken cancellationToken) => new List <ResourceIdentifier>()
            {
                new ResourceIdentifier(ResourceType.VirtualMachine, subscriptionId, resourceGroupName, "resourceName")
            });

            this.queryRunInfoProviderMock = new Mock <IQueryRunInfoProvider>();
        }