public void Permutate32BitText_ExpectNotEqualTexts()
        {
            var input        = _block.ConvertStringToBinaryString("ABcd");
            var permutedText = _block.Permutate32BitText(input);

            Assert.AreNotEqual(input, permutedText);
        }
Example #2
0
        public async Task SiloUngracefulShutdown_OutstandingRequestsBreak()
        {
            var grain      = HostedCluster.GrainFactory.GetGrain <ILongRunningTaskGrain <bool> >(Guid.NewGuid());
            var instanceId = await grain.GetRuntimeInstanceId();

            var target           = HostedCluster.GrainFactory.GetGrain <ILongRunningTaskGrain <bool> >(Guid.NewGuid());
            var targetInstanceId = await target.GetRuntimeInstanceId();

            Assert.AreNotEqual(instanceId, targetInstanceId, "Activations must be placed on different silos");
            var promise = instanceId.Contains(HostedCluster.Primary.Endpoint.ToString()) ?
                          grain.CallOtherLongRunningTask(target, true, TimeSpan.FromSeconds(7))
                : target.CallOtherLongRunningTask(grain, true, TimeSpan.FromSeconds(7));

            await Task.Delay(500);

            HostedCluster.KillSilo(HostedCluster.SecondarySilos[0]);
            try
            {
                await promise;
                Assert.Fail("The broken promise exception was not thrown");
            }
            catch (Exception ex)
            {
                Assert.AreEqual(typeof(SiloUnavailableException), ex.GetBaseException().GetType());
            }
        }
        public void ServiceId_SiloRestart()
        {
            Guid configServiceId = this.HostedCluster.Globals.ServiceId;

            var initialDeploymentId = this.HostedCluster.DeploymentId;

            output.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, ServiceId);

            Assert.AreEqual(ServiceId, configServiceId, "ServiceId in test config");

            output.WriteLine("About to reset Silos .....");
            output.WriteLine("Stopping Silos ...");
            this.HostedCluster.StopDefaultSilos();
            output.WriteLine("Starting Silos ...");
            this.HostedCluster.RedeployTestingSiloHost(SiloOptions);
            output.WriteLine("..... Silos restarted");

            output.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.Globals.ServiceId);

            Assert.AreEqual(ServiceId, this.HostedCluster.Globals.ServiceId, "ServiceId same after restart.");
            Assert.AreNotEqual(initialDeploymentId, this.HostedCluster.DeploymentId, "DeploymentId different after restart.");

            SiloHandle siloHandle = this.HostedCluster.GetActiveSilos().First();
            Guid       serviceId  = siloHandle.Silo.GlobalConfig.ServiceId;

            Assert.AreEqual(ServiceId, serviceId, "ServiceId in Silo config");
            serviceId = siloHandle.Silo.TestHook.ServiceId;
            Assert.AreEqual(ServiceId, serviceId, "ServiceId active in silo");

            // ServiceId is not currently available in client config
            //serviceId = ClientProviderRuntime.Instance.GetServiceId();
            //Assert.AreEqual(initialServiceId, serviceId, "ServiceId active in client");
        }
Example #4
0
        public async Task SMS_Limits_FindMax_Consumers()
        {
            // 1 Stream, 1 Producer, X Consumers

            Guid   streamId           = Guid.NewGuid();
            string streamProviderName = StreamTestsConstants.SMS_STREAM_PROVIDER_NAME;

            output.WriteLine("Starting search for MaxConsumersPerStream value using stream {0}", streamId);


            IStreamLifecycleProducerGrain producer = GrainClient.GrainFactory.GetGrain <IStreamLifecycleProducerGrain>(Guid.NewGuid());
            await producer.BecomeProducer(streamId, this.StreamNamespace, streamProviderName);

            int loopCount = 0;

            try
            {
                // Loop until something breaks!
                for (loopCount = 1; loopCount <= MaxExpectedPerStream; loopCount++)
                {
                    IStreamLifecycleConsumerGrain consumer = GrainClient.GrainFactory.GetGrain <IStreamLifecycleConsumerGrain>(Guid.NewGuid());
                    await consumer.BecomeConsumer(streamId, this.StreamNamespace, streamProviderName);
                }
            }
            catch (Exception exc)
            {
                output.WriteLine("Stopping loop at loopCount={0} due to exception {1}", loopCount, exc);
            }
            MaxConsumersPerStream = loopCount - 1;
            output.WriteLine("Finished search for MaxConsumersPerStream with value {0}", MaxConsumersPerStream);
            Assert.AreNotEqual(0, MaxConsumersPerStream, "MaxConsumersPerStream should be greater than zero.");
            output.WriteLine("MaxConsumersPerStream={0}", MaxConsumersPerStream);
        }
Example #5
0
        public void CodeGen_EncounteredFullySpecifiedInterfacesAreEncodedDistinctly()
        {
            var id1 = GrainInterfaceUtils.ComputeInterfaceId(typeof(IFullySpecified <int>));
            var id2 = GrainInterfaceUtils.ComputeInterfaceId(typeof(IFullySpecified <long>));

            Assert.AreNotEqual(id1, id2);
        }
Example #6
0
        public async Task PrimaryKeyExtensionsShouldDifferentiateGrainsUsingTheSameBasePrimaryKey()
        {
            var baseKey = Guid.NewGuid();

            const string kx1 = "1";
            const string kx2 = "2";

            var grain1   = GrainClient.GrainFactory.GetGrain <IKeyExtensionTestGrain>(baseKey, kx1, null);
            var grainId1 = await grain1.GetGrainReference();

            var activationId1 = await grain1.GetActivationId();

            var grain2   = GrainClient.GrainFactory.GetGrain <IKeyExtensionTestGrain>(baseKey, kx2, null);
            var grainId2 = await grain2.GetGrainReference();

            var activationId2 = await grain2.GetActivationId();

            Assert.AreNotEqual(
                grainId1,
                grainId2,
                "Mismatched key extensions should differentiate an identical base primary key.");

            Assert.AreNotEqual(
                activationId1,
                activationId2,
                "Mismatched key extensions should differentiate an identical base primary key.");
        }
Example #7
0
        public void GrainID_AsGuid()
        {
            string  guidString  = "0699605f-884d-4343-9977-f40a39ab7b2b";
            Guid    grainIdGuid = Guid.Parse(guidString);
            GrainId grainId     = GrainId.GetGrainIdForTesting(grainIdGuid);
            //string grainIdToKeyString = grainId.ToKeyString();
            string grainIdToFullString = grainId.ToFullString();
            string grainIdToGuidString = GrainIdToGuidString(grainId);
            string grainIdKeyString    = grainId.Key.ToString();

            output.WriteLine("Guid={0}", grainIdGuid);
            output.WriteLine("GrainId={0}", grainId);
            //output.WriteLine("GrainId.ToKeyString={0}", grainIdToKeyString);
            output.WriteLine("GrainId.Key.ToString={0}", grainIdKeyString);
            output.WriteLine("GrainIdToGuidString={0}", grainIdToGuidString);
            output.WriteLine("GrainId.ToFullString={0}", grainIdToFullString);

            // Equal: Public APIs
            //Assert.AreEqual(guidString, grainIdToKeyString, "GrainId.ToKeyString");
            Assert.AreEqual(guidString, grainIdToGuidString, "GrainIdToGuidString");
            // Equal: Internal APIs
            Assert.AreEqual(grainIdGuid, grainId.GetPrimaryKey(), "GetPrimaryKey Guid");
            // NOT-Equal: Internal APIs
            Assert.AreNotEqual(guidString, grainIdKeyString, "GrainId.Key.ToString");
        }
Example #8
0
        public async Task PrimaryKeyExtensionsShouldDifferentiateGrainsUsingDifferentBaseKeys()
        {
            var baseKey1 = Guid.NewGuid();
            var baseKey2 = Guid.NewGuid();

            const string kx = "1";

            var grain1   = GrainClient.GrainFactory.GetGrain <IKeyExtensionTestGrain>(baseKey1, kx, null);
            var grainId1 = await grain1.GetGrainReference();

            var activationId1 = await grain1.GetActivationId();

            var grain2   = GrainClient.GrainFactory.GetGrain <IKeyExtensionTestGrain>(baseKey2, kx, null);
            var grainId2 = await grain2.GetGrainReference();

            var activationId2 = await grain2.GetActivationId();

            Assert.AreNotEqual(
                grainId1,
                grainId2,
                "Mismatched base keys should differentiate between identical extended keys.");

            Assert.AreNotEqual(
                activationId1,
                activationId2,
                "Mismatched base keys should differentiate between identical extended keys.");
        }
Example #9
0
        public async Task PreferLocalPlacementGrain_ShouldMigrateWhenHostSiloKilled(string value)
        {
            await HostedCluster.WaitForLivenessToStabilizeAsync();

            output.WriteLine("******************** Starting test ({0}) ********************", value);
            TestSilosStarted(2);

            foreach (SiloHandle silo in HostedCluster.GetActiveSilos())
            {
                NodeConfiguration cfg = silo.Silo.LocalConfig;
                Assert.IsNotNull(cfg, "NodeConfiguration should be present for silo " + silo);
                output.WriteLine(
                    "Silo {0} : Address = {1} Proxy gateway: {2}",
                    cfg.SiloName, cfg.Endpoint, cfg.ProxyGatewayEndpoint);
            }

            IPEndPoint targetSilo;

            if (value == "Primary")
            {
                targetSilo = HostedCluster.Primary.Endpoint;
            }
            else
            {
                targetSilo = HostedCluster.Secondary.Endpoint;
            }
            Guid proxyKey;
            IRandomPlacementTestGrain proxy;
            IPEndPoint expected;

            do
            {
                proxyKey = Guid.NewGuid();
                proxy    = GrainFactory.GetGrain <IRandomPlacementTestGrain>(proxyKey);
                expected = await proxy.GetEndpoint();
            } while (!targetSilo.Equals(expected));
            output.WriteLine("Proxy grain was originally located on silo {0}", expected);

            Guid grainKey = proxyKey;
            await proxy.StartPreferLocalGrain(grainKey);

            IPreferLocalPlacementTestGrain grain = GrainFactory.GetGrain <IPreferLocalPlacementTestGrain>(grainKey);
            IPEndPoint actual = await grain.GetEndpoint();

            output.WriteLine("PreferLocalPlacement grain was originally located on silo {0}", actual);
            Assert.AreEqual(expected, actual,
                            "PreferLocalPlacement strategy should create activations on the local silo.");

            SiloHandle siloToKill = HostedCluster.GetActiveSilos().First(s => s.Endpoint.Equals(expected));

            output.WriteLine("Killing silo {0} hosting locally placed grain", siloToKill);
            HostedCluster.StopSilo(siloToKill);

            IPEndPoint newActual = await grain.GetEndpoint();

            output.WriteLine("PreferLocalPlacement grain was recreated on silo {0}", newActual);
            Assert.AreNotEqual(expected, newActual,
                               "PreferLocalPlacement strategy should recreate activations on other silo if local fails.");
        }
        public void ToMD5_PassIncorrectSentence_ReturnInCorrectEncryption()
        {
            string input    = "The quickXXX brown fox jumps over the lazy dog";
            string expected = "9e107d9d372bb6826bd81d3542a419d6";
            string actual   = input.ToMD5();

            Assert.AreNotEqual(expected, actual);
        }
        public void Encrypt_PassString_IncorrectPassPhrase_NotEncrypted()
        {
            var str             = "this string will be encrypted";
            var encryptedString = str.Encrypt("pp for encryption");
            var decryptedString = encryptedString.Decrypt("wrong pp for encryption");

            Assert.AreNotEqual(str, decryptedString);
        }
Example #12
0
        public void Interning_SiloAddress2()
        {
            SiloAddress a1 = SiloAddress.New(new IPEndPoint(IPAddress.Loopback, 1111), 12345);
            SiloAddress a2 = SiloAddress.New(new IPEndPoint(IPAddress.Loopback, 2222), 12345);

            Assert.AreNotEqual(a1, a2, "Should not be equal SiloAddress's");
            Assert.AreNotSame(a1, a2, "Should not be same / intern'ed SiloAddress object");
        }
Example #13
0
        public void InsertPlainttextIntoEncrpytion_expectSomeCipherText_withGenericKey()
        {
            var plainText  = "abc123av";
            var key        = "12345678";
            var cipherText = _logic.Encrypt(plainText, key);

            Assert.AreNotEqual(plainText, cipherText);
        }
Example #14
0
        private Task Test_Stream_Churn_NumStreams(
            string streamProviderName,
            int pipelineSize,
            int numStreams,
            int numConsumers          = 9,
            int numProducers          = 1,
            bool warmUpPubSub         = true,
            bool normalSubscribeCalls = true)
        {
            output.WriteLine("Testing churn with {0} Streams with {1} Consumers and {2} Producers per Stream NormalSubscribe={3}",
                             numStreams, numConsumers, numProducers, normalSubscribeCalls);

            AsyncPipeline pipeline = new AsyncPipeline(pipelineSize);
            var           promises = new List <Task>();

            // Create streamId Guids
            Guid[] streamIds = new Guid[numStreams];
            for (int i = 0; i < numStreams; i++)
            {
                streamIds[i] = Guid.NewGuid();
            }

            if (warmUpPubSub)
            {
                WarmUpPubSub(streamProviderName, streamIds, pipeline);

                pipeline.Wait();

                int activePubSubGrains = ActiveGrainCount(typeof(PubSubRendezvousGrain).FullName);
                Assert.AreEqual(streamIds.Length, activePubSubGrains, "Initial PubSub count -- should all be warmed up");
            }

            int activeConsumerGrains = ActiveGrainCount(typeof(StreamLifecycleConsumerGrain).FullName);

            Assert.AreEqual(0, activeConsumerGrains, "Initial Consumer count should be zero");

            Stopwatch sw = Stopwatch.StartNew();

            for (int i = 0; i < numStreams; i++)
            {
                Task promise = SetupOneStream(streamIds[i], streamProviderName, pipeline, numConsumers, numProducers, normalSubscribeCalls);
                promises.Add(promise);
            }
            Task.WhenAll(promises).Wait();
            sw.Stop();

            int consumerCount = ActiveGrainCount(typeof(StreamLifecycleConsumerGrain).FullName);

            Assert.AreEqual(activeConsumerGrains + (numStreams * numConsumers), consumerCount, "The correct number of new Consumer grains are active");

            TimeSpan elapsed            = sw.Elapsed;
            int      totalSubscriptions = numStreams * numConsumers;
            double   rps = totalSubscriptions / elapsed.TotalSeconds;

            output.WriteLine("Subscriptions-per-second = {0} during period {1}", rps, elapsed);
            Assert.AreNotEqual(0.0, rps, "RPS greater than zero");
            return(TaskDone.Done);
        }
Example #15
0
 public void TestIncome()
 {
     game.Person.Mood = 95;
     factory.CreatePersonService().NewJob(game, 1);
     Assert.AreEqual(15, game.Person.Income);
     game.Person.Mood = 8;
     factory.CreatePersonService().IncomeCalculate(game);
     Assert.AreNotEqual(10, game.Person.Income);
 }
        public void GivenSameWordWithNoSaltWhenHashedTheHashIsDifferent()
        {
            var inputWord = Root.Any.String();

            var firstHashResult  = _sut.CreateHash(inputWord);
            var secondHashResult = _sut.CreateHash(inputWord);

            Assert.AreNotEqual(firstHashResult.Hash, secondHashResult.Hash);
            Assert.AreNotEqual(firstHashResult.Salt, secondHashResult.Salt);
        }
Example #17
0
        public void TestPermutate()
        {
            var block            = new Block();
            var blocks           = block.SplitBlockIntoStrings("ABCD1234");
            var permutatedBlocks = _logic.PermutateTwoBlocks(blocks);

            Assert.AreNotEqual(blocks, permutatedBlocks);
            Assert.AreEqual(blocks[1], permutatedBlocks[0]);
            Assert.AreEqual(blocks[0], permutatedBlocks[1]);
        }
        public void GivenDifferentWordsAndSameSaltWhenHashedTheHashIsDifferent()
        {
            var firstInputWord  = Root.Any.String();
            var secondInputWord = Root.Any.String();

            var firstHashResult  = _sut.CreateHash(firstInputWord);
            var secondHashResult = _sut.CreateHash(secondInputWord, firstHashResult.Salt);

            Assert.AreNotEqual(firstHashResult.Hash, secondHashResult.Hash);
            Assert.AreEqual(firstHashResult.Salt, secondHashResult.Salt);
        }
Example #19
0
        public void OnNoRelationshipNoError_WhenAddedOnList()
        {
            var master = new Employee();
            var child  = new Child()
            {
                Name = "ChildName", EmployeeId = 1
            };

            master.Id = 2;
            master.Children.Add(child);
            Assert.AreNotEqual(master.Id, child.EmployeeId);
        }
Example #20
0
 private static void CheckNotEquals(object obj, object other)
 {
     Assert.IsNotNull(obj);
     Assert.IsNotNull(other);
     Assert.AreNotEqual(obj, other);
     Assert.AreNotEqual(other, obj);
     Assert.AreNotEqual(obj.GetHashCode(), other.GetHashCode());
     Assert.IsFalse(obj.Equals(other));
     Assert.IsFalse(other.Equals(obj));
     Assert.IsFalse(obj == other);
     Assert.IsFalse(other == obj);
     Assert.IsTrue(obj != other);
     Assert.IsTrue(other != obj);
 }
Example #21
0
        public void SwapTest()
        {
            string a = "Test", b = "Unit";

            Assert.AreEqual("Unit", b);
            Assert.AreNotEqual("Unit", a);
            Assert.AreEqual("Test", a);
            Assert.AreNotEqual("Test", b);
            ValueUtils.Swap(ref a, ref b);
            Assert.AreEqual("Unit", a);
            Assert.AreNotEqual("Unit", b);
            Assert.AreEqual("Test", b);
            Assert.AreNotEqual("Test", a);
        }
Example #22
0
        private async Task StateClassTests_Test(string grainClass)
        {
            var grain           = GrainFactory.GetGrain <ISimplePersistentGrain>(GetRandomGrainId(), grainClass);
            var originalVersion = await grain.GetVersion();

            await grain.SetA(98, true);                // deactivate grain after setting A

            var newVersion = await grain.GetVersion(); // get a new version from the new activation

            Assert.AreNotEqual(originalVersion, newVersion);
            var a = await grain.GetA();

            Assert.AreEqual(98, a); // value of A survive deactivation and reactivation of the grain
        }
        public void GetFlights_ShouldReturnFlightss()
        {
            {
                //add Flights plan to the db
                DataBase.flightPlanDB.Add("00", new FlightPlan
                {
                    Passengers       = 400,
                    Company_Name     = "Our_company",
                    Initial_location = new InitialLocation
                    {
                        Longitude = 90,
                        Latitude  = 21,
                        Date_time = "2020-06-05T09:23:00Z"
                    },
                    Segments = new List <Segment>()
                    {
                        new Segment
                        {
                            Longitude        = 20,
                            Latitude         = 20,
                            Timespan_seconds = 100
                        }
                    }
                });
                //the function from the FlightsController
                Mock <FlightsController> controller = new Mock <FlightsController>();
                controller.Setup(x => x.flightsCheck(It.IsAny <string>()))
                .Returns(ReturnFlightss());

                //ACT
                var listFlightss =
                    controller.Object.GetFlightsByDateTimeForTest("2020-06-05T09:23:00Z").Result;

                //Assert
                //check it is equal
                Assert.AreEqual(listFlightss.Count, 1);
                Assert.AreEqual(listFlightss[0].Passengers, 400);
                Assert.AreEqual(listFlightss[0].Is_external, false);
                Assert.AreEqual(listFlightss[0].Company_name, "Our_company");
                Assert.AreEqual(listFlightss[0].Date_time, "2020-06-05T09:23:00Z");

                //check it is not equal
                Assert.AreNotEqual(listFlightss.Count, 2);
                Assert.AreNotEqual(listFlightss.Count, 3);
                Assert.AreNotEqual(listFlightss[0].Passengers, 102);
                Assert.AreNotEqual(listFlightss[0].Is_external, true);
                Assert.AreNotEqual(listFlightss[0].Company_name, "Failier");
            }
        }
Example #24
0
        public async Task RequestContext_ActivityId_DynamicChange_Server()
        {
            Guid activityId  = Guid.NewGuid();
            Guid activityId2 = Guid.NewGuid();

            const string PropagateActivityIdConfigKey = @"/OrleansConfiguration/Defaults/Tracing/@PropagateActivityId";
            var          changeConfig = new Dictionary <string, string>();

            IManagementGrain mgmtGrain = GrainClient.GrainFactory.GetGrain <IManagementGrain>(RuntimeInterfaceConstants.SYSTEM_MANAGEMENT_ID);

            IRequestContextTestGrain grain = GrainClient.GrainFactory.GetGrain <IRequestContextTestGrain>(GetRandomGrainId());

            Trace.CorrelationManager.ActivityId = activityId;
            Guid result = await grain.E2EActivityId();

            Assert.AreEqual(activityId, result, "E2E ActivityId #1 not propagated correctly");
            RequestContext.Clear();

            changeConfig[PropagateActivityIdConfigKey] = Boolean.FalseString;
            output.WriteLine("Set {0}={1}", PropagateActivityIdConfigKey, changeConfig[PropagateActivityIdConfigKey]);
            await mgmtGrain.UpdateConfiguration(null, changeConfig, null);

            Trace.CorrelationManager.ActivityId = activityId2;
            result = await grain.E2EActivityId();

            Assert.AreNotEqual(activityId2, result, "E2E ActivityId #2 should not have been propagated");
            Assert.AreEqual(Guid.Empty, result, "E2E ActivityId #2 should not have been propagated");
            RequestContext.Clear();

            changeConfig[PropagateActivityIdConfigKey] = Boolean.TrueString;
            output.WriteLine("Set {0}={1}", PropagateActivityIdConfigKey, changeConfig[PropagateActivityIdConfigKey]);
            await mgmtGrain.UpdateConfiguration(null, changeConfig, null);

            Trace.CorrelationManager.ActivityId = activityId2;
            result = await grain.E2EActivityId();

            Assert.AreEqual(activityId2, result, "E2E ActivityId #2 should have been propagated");
            RequestContext.Clear();

            Trace.CorrelationManager.ActivityId = activityId;
            result = await grain.E2EActivityId();

            Assert.AreEqual(activityId, result, "E2E ActivityId #1 not propagated correctly after #2");
            RequestContext.Clear();
        }
        public void Feature_DependencyInjection_ViewModelScopedService()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_DependencyInjection_ViewModelScopedService);

                for (int i = 0; i < 5; i++)
                {
                    var value = browser.First(".result").GetInnerText();
                    AssertUI.InnerTextEquals(browser.First(".result2"), value);

                    browser.First("input[type=button]").Click().Wait();
                    var value2 = browser.First(".result").GetInnerText();
                    AssertUI.InnerTextEquals(browser.First(".result2"), value2);

                    Assert.AreNotEqual(value, value2);
                }
            });
        }
        public void NullToNoneTest()
        {
            Assert.AreEqual("None", TextUtils.NullToNone(null));
            Assert.AreEqual(TextUtils.None, TextUtils.NullToNone(null));
            Assert.AreEqual(TextUtils.None, TextUtils.NullToNone(" n o n e "));
            Assert.AreNotEqual(TextUtils.None, TextUtils.NullToNone("Nessuno"));
            Assert.AreEqual("Nessuno", TextUtils.NullToNone("Nessuno"));
            Assert.AreEqual("Intersect", TextUtils.NullToNone("Intersect"));

            TextUtils.None = "Nessuno";

            Assert.AreEqual("Nessuno", TextUtils.NullToNone(null));
            Assert.AreEqual(TextUtils.None, TextUtils.NullToNone(null));
            Assert.AreEqual(TextUtils.None, TextUtils.NullToNone(" n o n e "));
            Assert.AreEqual(TextUtils.None, TextUtils.NullToNone("Nessuno"));
            Assert.AreEqual("Nessuno", TextUtils.NullToNone("Nessuno"));
            Assert.AreEqual("Intersect", TextUtils.NullToNone("Intersect"));
        }
Example #27
0
        /// <summary>
        /// Loads the simple project and makes sure we get the correct module.
        /// </summary>
        public void EnumModules(VisualStudioApp app, DotNotWaitOnNormalExit optionSetter)
        {
            StartHelloWorldAndBreak(app);

            var modules = ((Process3)app.Dte.Debugger.CurrentProcess).Modules;

            Assert.IsTrue(modules.Count >= 1);

            var module = modules.Item("__main__");

            Assert.IsNotNull(module);

            Assert.IsTrue(module.Path.EndsWith("Program.py"));
            Assert.AreEqual("__main__", module.Name);
            Assert.AreNotEqual((uint)0, module.Order);

            app.Dte.Debugger.TerminateAll();
            WaitForMode(app, dbgDebugMode.dbgDesignMode);
        }
        public async Task Sched_AC_Turn_Execution_Order()
        {
            // Can we add a unit test that basicaly checks that any turn is indeed run till completion before any other turn?
            // For example, you have a  long running main turn and in the middle it spawns a lot of short CWs (on Done promise) and StartNew.
            // You test that no CW/StartNew runs until the main turn is fully done. And run in stress.

            UnitTestSchedulingContext context = new UnitTestSchedulingContext();

            orleansTaskScheduler = TestInternalHelper.InitializeSchedulerForTesting(context);

            var result1 = new TaskCompletionSource <bool>();
            var result2 = new TaskCompletionSource <bool>();

            orleansTaskScheduler.QueueWorkItem(new ClosureWorkItem(() =>
            {
                mainDone  = false;
                stageNum1 = stageNum2 = 0;

                Task task1 = Task.Factory.StartNew(() => SubProcess1(11));
                Task task2 = task1.ContinueWith((_) => SubProcess1(12));
                Task task3 = task2.ContinueWith((_) => SubProcess1(13));
                Task task4 = task3.ContinueWith((_) => { SubProcess1(14); result1.SetResult(true); });
                task4.Ignore();

                Task task21 = TaskDone.Done.ContinueWith((_) => SubProcess2(21));
                Task task22 = task21.ContinueWith((_) => { SubProcess2(22); result2.SetResult(true); });
                task22.Ignore();

                Thread.Sleep(TimeSpan.FromSeconds(1));
                mainDone = true;
            }), context);

            try { await result1.Task.WithTimeout(TimeSpan.FromSeconds(3)); }
            catch (TimeoutException) { Assert.Fail("Timeout-1"); }
            try { await result2.Task.WithTimeout(TimeSpan.FromSeconds(3)); }
            catch (TimeoutException) { Assert.Fail("Timeout-2"); }

            Assert.AreNotEqual(0, stageNum1, "Work items did not get executed-1");
            Assert.AreNotEqual(0, stageNum2, "Work items did not get executed-2");
            Assert.AreEqual(14, stageNum1, "Work items executed out of order-1");
            Assert.AreEqual(22, stageNum2, "Work items executed out of order-2");
        }
Example #29
0
        public async Task Generic_Non_Primitive_Type_Argument()
        {
            IEchoHubGrain <Guid, string> g1 = GrainFactory.GetGrain <IEchoHubGrain <Guid, string> >(1);
            IEchoHubGrain <Guid, int>    g2 = GrainFactory.GetGrain <IEchoHubGrain <Guid, int> >(1);
            IEchoHubGrain <Guid, byte[]> g3 = GrainFactory.GetGrain <IEchoHubGrain <Guid, byte[]> >(1);

            Assert.AreNotEqual((GrainReference)g1, (GrainReference)g2);
            Assert.AreNotEqual((GrainReference)g1, (GrainReference)g3);
            Assert.AreNotEqual((GrainReference)g2, (GrainReference)g3);

            await g1.Foo(Guid.Empty, "", 1);

            await g2.Foo(Guid.Empty, 0, 2);

            await g3.Foo(Guid.Empty, new byte[] { }, 3);

            Assert.AreEqual(1, await g1.GetX());
            Assert.AreEqual(2, await g2.GetX());
            Assert.AreEqual(3m, await g3.GetX());
        }
Example #30
0
        public void Baseline_StreamRel_RestartSilos()
        {
            // This test case is just a sanity-check that the silo test config is OK.
            const string testName = "Baseline_StreamRel_RestartSilos";

            StreamTestUtils.LogStartTest(testName, _streamId, _streamProviderName, logger);

            CheckSilosRunning("Before Restart", numExpectedSilos);
            SiloHandle prim1 = this.HostedCluster.Primary;
            SiloHandle sec1  = this.HostedCluster.Secondary;

            RestartAllSilos();

            CheckSilosRunning("After Restart", numExpectedSilos);

            Assert.AreNotEqual(prim1, this.HostedCluster.Primary, "Should be different Primary silos after restart");
            Assert.AreNotEqual(sec1, this.HostedCluster.Secondary, "Should be different Secondary silos after restart");

            StreamTestUtils.LogEndTest(testName, logger);
        }