AreSame() public static method

public static AreSame ( object x, object y, string msg ) : void
x object
y object
msg string
return void
        public void SendDirectMessageResponse()
        {
            IProtocolMessage message = new TestDirectedMessage {
                Age      = 15,
                Name     = "Andrew",
                Location = new Uri("http://hostb/pathB"),
            };

            OutgoingWebResponse response = this.channel.PrepareResponse(message);

            Assert.AreSame(message, response.OriginalMessage);
            Assert.AreEqual(HttpStatusCode.OK, response.Status);
            Assert.AreEqual(0, response.Headers.Count);

            NameValueCollection body = HttpUtility.ParseQueryString(response.Body);

            Assert.AreEqual("15", body["age"]);
            Assert.AreEqual("Andrew", body["Name"]);
            Assert.AreEqual("http://hostb/pathB", body["Location"]);
        }
Example #2
0
        public void clicking_slot_moves_selected_item_to_clicked_slot()
        {
            var inventoryPanel = inventory_helpers.GetInventoryPanelWithItems(2);

            var slots = inventoryPanel.Slots.ToArray();

            var slot0 = slots[0];
            var slot1 = slots[1];
            var item0 = slot0.Item;
            var item1 = slot1.Item;

            Assert.IsNotNull(item0);
            Assert.IsNotNull(item1);

            slot0.OnPointerDown(null);
            slot1.OnPointerDown(null);

            Assert.AreSame(item0, slot1.Item);
            Assert.AreSame(item1, slot0.Item);
        }
        public IEnumerator WindowHandler_OnSceneGUIUpdate_Method()
        {
            var camera        = SceneView.GetAllSceneCameras().FirstOrDefault();
            var windowFactory = new Window.Factory();
            var mockHandler   = new WindowHandler(windowFactory, camera);

            var mockTransform = new GameObject().transform;

            Selection.SetActiveObjectWithContext(mockTransform, null);
            mockHandler.OnSceneSelectedObjects();

            var onGUIUpdate = new Action <SceneView>(delegate { mockHandler.OnSceneGUIUpdate(); });

            SceneView.duringSceneGui += onGUIUpdate;
            yield return(null);

            SceneView.duringSceneGui -= onGUIUpdate;

            Assert.AreSame(mockTransform, Selection.activeTransform);
        }
Example #4
0
        private static async Task Inner(Container container, ICommand command)
        {
            DisposableCommand cmd1, cmd2;

            await Task.Yield();

            cmd1 = container.GetInstance <DisposableCommand>();
            Assert.AreSame(command, cmd1);

            using (AsyncScopedLifestyle.BeginScope(container))
            {
                // Act
                cmd2 = container.GetInstance <DisposableCommand>();

                Assert.AreNotSame(command, cmd2);
                Assert.IsFalse(cmd2.HasBeenDisposed);
            }

            Assert.IsTrue(cmd2.HasBeenDisposed);
        }
        //-------------------------------------------------------
        //private helper

        private static void CheckExampleServicesResolve(IContainer container)
        {
            using (var lifetimeScope = container.BeginLifetimeScope())
            {
                //DataLayer - Data classes

                //DataLayer - repositories
                var db1 = lifetimeScope.Resolve <IGenericServicesDbContext>();
                var db2 = lifetimeScope.Resolve <IGenericServicesDbContext>();
                Assert.NotNull(db1);
                Assert.AreSame(db1, db2);                       //check that lifetimescope is working

                //ServiceLayer - complex
                var service1 = lifetimeScope.Resolve <IListService>();
                var service2 = lifetimeScope.Resolve <IListService>();
                Assert.NotNull(service1);
                Assert.AreNotSame(service1, service2);                       //check transient
                (service1 is ListService).ShouldEqual(true);
            }
        }
        public async Task GetCustomer_IncludeSoftDeleted_ReturnsDeletedRecordInResult()
        {
            // Arrange
            var testCustomer = new Customer
            {
                Id        = 3000,
                IsDeleted = true
            };

            this.customersRepository.Refresh(new List <Customer> {
                testCustomer
            });

            // Act
            var actual = await this.sut.GetCustomer(testCustomer.Id, true);

            // Assert
            Assert.IsNotNull(actual);
            Assert.AreSame(testCustomer, actual);
        }
Example #7
0
        public void ManageabilityProviderIsProperlyRegistered()
        {
            ConfigurationElementManageabilityProviderAttribute selectedAttribute = null;

            Assembly assembly = typeof(SymmetricAlgorithmProviderDataManageabilityProvider).Assembly;

            foreach (ConfigurationElementManageabilityProviderAttribute providerAttribute
                     in assembly.GetCustomAttributes(typeof(ConfigurationElementManageabilityProviderAttribute), false))
            {
                if (providerAttribute.ManageabilityProviderType.Equals(typeof(SymmetricAlgorithmProviderDataManageabilityProvider)))
                {
                    selectedAttribute = providerAttribute;
                    break;
                }
            }

            Assert.IsNotNull(selectedAttribute);
            Assert.AreSame(typeof(CryptographySettingsManageabilityProvider), selectedAttribute.SectionManageabilityProviderType);
            Assert.AreSame(typeof(SymmetricAlgorithmProviderData), selectedAttribute.TargetType);
        }
Example #8
0
        public async Task ReportView_MinimalInformation()
        {
            var sink = new PiwikSink(defaultOptions);

            Api.PiwikViewInfo calledViewInfo = null;
            mockApi
            .Setup(api => api.ReportViewAsync(It.IsAny <Api.PiwikViewInfo>()))
            .Returns(Task.FromResult(true))
            .Callback <Api.PiwikViewInfo>(vi => calledViewInfo = vi);

            await telemetryProvider.Activity.ReportViewAsync(new Core.ViewInfo());

            Assert.IsNotNull(calledViewInfo);
            Assert.AreEqual(sink.BaseAppUrl.ToString(), calledViewInfo.Url);
            Assert.IsNull(calledViewInfo.ViewName);
            Assert.IsNull(calledViewInfo.ReferrerUrl);
            Assert.IsFalse(calledViewInfo.ViewTime.HasValue);
            Assert.AreSame(sink.Session, calledViewInfo.Session);
            Assert.AreSame(sink.EnvironmentInfo, calledViewInfo.EnvironmentInfo);
        }
Example #9
0
        public void NewValidateUserResponse_ValidParams_ReturnsResponse()
        {
            var guid = Guid.NewGuid();

            var test = assembler.NewValidateUserResponse(validDataModel, guid);

            Assert.IsNotNull(test);
            Assert.IsNotNull(test.User);

            Assert.IsInstanceOf <ValidateUserResponse>(test);

            Assert.IsTrue(test.LoginSuccess);

            Assert.AreSame(validDataModel.EmailAddress, test.User.EmailAddress);
            Assert.AreSame(validDataModel.FirstName, test.User.FirstName);
            Assert.AreSame(validDataModel.LastName, test.User.LastName);

            Assert.AreEqual(validDataModel.DateOfBirth, test.User.DateOfBirth);
            Assert.AreEqual(test.RequestReference, guid);
        }
Example #10
0
        public void Given_Thread_reuse_Services_resolved_in_same_thread_should_be_the_same_In_nested_scope_too()
        {
            var container = new Container(scopeContext: new ThreadScopeContext());

            using (var scope = container.OpenScope("root"))
            {
                container.Register <Service>(Reuse.ScopedTo("root"));

                var one = scope.Resolve <Service>();

                using (var nested = scope.OpenScope())
                {
                    var two = nested.Resolve <Service>();
                    Assert.AreSame(one, two);
                }

                var another = container.Resolve <Service>();
                Assert.AreSame(one, another);
            }
        }
Example #11
0
        public void TestConstructWithProperty()
        {
            var property = new TestClass1();

            SimpleIoc.Default.Reset();
            SimpleIoc.Default.Register(
                () => new TestClass6
                {
                    MyProperty = property
                });

            var instance1 = new TestClass6();
            Assert.IsNotNull(instance1);
            Assert.IsNull(instance1.MyProperty);

            var instance2 = SimpleIoc.Default.GetInstance<TestClass6>();
            Assert.IsNotNull(instance2);
            Assert.IsNotNull(instance2.MyProperty);
            Assert.AreSame(property, instance2.MyProperty);
        }
        public void MoreThanOneMatcher__Must_ReturnWhateverMatchesTheMatcherReturns(
            IList <Tuple <StatementEntry, TransactionDetails> > expectedMatches)
        {
            Setup_PrimaryItemMatcher_ToReturn(new List <Tuple <StatementEntry, TransactionDetails> > {
            });

            var secondaryMatcher = new Mock <IMatchFinder <StatementEntry, TransactionDetails> >();

            Setup_ItemMatcher_ToReturn(secondaryMatcher, expectedMatches);

            matchers.Add(secondaryMatcher.Object);

            var statementEntries = new StatementEntry[] { new StatementEntry() };
            var transactions     = new TransactionDetails[] { new TransactionDetails() };

            var matchGroups = target.Compare(statementEntries, transactions).MatchGroups;

            Assert.AreEqual(2, matchGroups.Count, "The must be two match groups");
            Assert.AreSame(expectedMatches, matchGroups.Skip(1).First());
        }
Example #13
0
        public void TestGetParameter()
        {
            // GIVEN an expression for the parameter
            ParameterExpression parameter = Expression.Parameter(typeof(TestClass));

            // WHEN a param is requested and the null check mode is set to None
            ParameterProvider <TestClass> parameterProvider = new ParameterProvider <TestClass>(parameter, BindingFlags.Instance | BindingFlags.Public, NullCheckMode.None);
            Expression result = parameterProvider.GetParameter("StringProperty");

            // THEN the returned expression is a method call
            Assert.IsInstanceOfType(result, typeof(MethodCallExpression));

            // AND the expression contains the correct parameter
            Assert.AreSame(parameter, ((MethodCallExpression)result).Object);

            // AND the expression contains the getter being accessed
            MethodInfo?methodInfo = typeof(TestClass).GetProperty("StringProperty", BindingFlags.Instance | BindingFlags.Public)?.GetGetMethod();

            Assert.AreSame(methodInfo, ((MethodCallExpression)result).Method);
        }
Example #14
0
    public void Example()
    {
        var container = new Container();

        container.Register <Car>(Reuse.ScopedTo("top"));

        using (var s1 = container.OpenScope("top"))
        {
            var car1 = s1.Resolve <Car>();

            using (var s2 = s1.OpenScope())
            {
                var car2 = s2.Resolve <Car>();

                // Cars are the same despite that `car2` is resolved from the nested `s2`,
                // because it was specifically resolved from the matching name scope `s1`
                Assert.AreSame(car2, car1);
            }
        }
    }
Example #15
0
        public void AsModelBinderForTypesRegistersInstanceModelBinder()
        {
            IDependencyResolver originalResolver = null;

            try
            {
                originalResolver = DependencyResolver.Current;
                var builder = new ContainerBuilder();
                var binder  = new TestModelBinder();
                builder.RegisterInstance(binder).AsModelBinderForTypes(typeof(TestModel1));
                var container = builder.Build();
                DependencyResolver.SetResolver(new AutofacDependencyResolver(container, new StubLifetimeScopeProvider(container)));
                var provider = new AutofacModelBinderProvider();
                Assert.AreSame(binder, provider.GetBinder(typeof(TestModel1)));
            }
            finally
            {
                DependencyResolver.SetResolver(originalResolver);
            }
        }
        public void ICloneableClone()
        {
            RandomAccessQueue<object> queue = new RandomAccessQueue<object>();

            object first = new object();
            object second = new object();
            queue.Enqueue(first);
            queue.Enqueue(second);

            ICloneable cloneable = queue;
            RandomAccessQueue<object> clone = (RandomAccessQueue<object>)cloneable.Clone();

            Assert.AreEqual(queue.Count, clone.Count);

            Assert.AreSame(first, queue.Dequeue());
            Assert.AreSame(first, clone.Dequeue());
            Assert.AreSame(second, queue.Dequeue());
            Assert.AreSame(second, clone.Dequeue());
            Assert.AreNotSame(queue.SyncRoot, clone.SyncRoot);
        }
Example #17
0
        public void DomDominatorCommon()
        {
            Procedure proc = new DiamondMock().Procedure;
            var       doms = proc.CreateBlockDominatorGraph();
            Block     head = proc.EntryBlock.Succ[0];
            Block     f    = head.ElseBlock;
            Block     t    = head.ThenBlock;
            Block     join = t.Succ[0];

            Assert.AreEqual("false", f.Name);
            Assert.AreEqual("true", t.Name);
            Assert.AreEqual("join", join.Name);
            Assert.IsNull(doms.CommonDominator(null), "Common denominator of no items is null");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { head }), "Common dominator of single item is that item");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { head, t }), "head dom true");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { t, head }), "head dom true");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { head, f }), "head dom true");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { f, head }), "head dom true");
            Assert.AreSame(head, doms.CommonDominator(new Block[] { f, t }), "head dom true");
        }
Example #18
0
        public async Task Can_resync_if_missed_a_block()
        {
            _remoteBlockTree = Build.A.BlockTree(_genesisBlock).OfChainLength(SynchronizationManager.BatchSize).TestObject;
            ISynchronizationPeer peer = new SynchronizationPeerMock(_remoteBlockTree);

            ManualResetEvent resetEvent = new ManualResetEvent(false);

            _manager.SyncEvent += (sender, args) => { resetEvent.Set(); };
            Task addPeerTask     = _manager.AddPeer(peer);
            Task firstToComplete = await Task.WhenAny(addPeerTask, Task.Delay(2000));

            Assert.AreSame(addPeerTask, firstToComplete);
            _manager.Start();
            resetEvent.WaitOne(TimeSpan.FromMilliseconds(2000));

            BlockTreeBuilder.ExtendTree(_remoteBlockTree, SynchronizationManager.BatchSize * 2);
            _manager.AddNewBlock(_remoteBlockTree.RetrieveHeadBlock(), peer.NodeId);

            Assert.AreEqual(SynchronizationManager.BatchSize * 2 - 1, (int)_blockTree.BestSuggested.Number);
        }
Example #19
0
        public void ProcessDependencies_Reorders_SimpleDependencies()
        {
            // arrange
            // A ◀── B
            // ▲     ▲
            // │     │
            // └─ C ─┘
            Mock <IModMetadata> modA = this.GetMetadata("Mod A");
            Mock <IModMetadata> modB = this.GetMetadata("Mod B", dependencies: new[] { "Mod A" });
            Mock <IModMetadata> modC = this.GetMetadata("Mod C", dependencies: new[] { "Mod A", "Mod B" });

            // act
            IModMetadata[] mods = new ModResolver().ProcessDependencies(new[] { modC.Object, modA.Object, modB.Object }, new ModDatabase()).ToArray();

            // assert
            Assert.AreEqual(3, mods.Length, 0, "Expected to get the same number of mods input.");
            Assert.AreSame(modA.Object, mods[0], "The load order is incorrect: mod A should be first since the other mods depend on it.");
            Assert.AreSame(modB.Object, mods[1], "The load order is incorrect: mod B should be second since it needs mod A, and is needed by mod C.");
            Assert.AreSame(modC.Object, mods[2], "The load order is incorrect: mod C should be third since it needs both mod A and mod B.");
        }
        public void CreateCachedController_UnderlyingFactoryReturnsController()
        {
            // Arrange
            RequestContext  requestContext = GetRequestContext();
            EmptyController controller     = new EmptyController();

            Mock <IControllerFactory> mockUnderlyingFactory = new Mock <IControllerFactory>();

            mockUnderlyingFactory.Expect(o => o.CreateController(requestContext, "home")).Returns(controller).AtMostOnce();
            MvcDynamicSessionControllerFactory factory = new MvcDynamicSessionControllerFactory(mockUnderlyingFactory.Object);

            // Act
            IController controller1 = factory.CreateCachedController(requestContext, "home");
            IController controller2 = factory.CreateController(requestContext, "home");

            // Assert
            Assert.AreEqual(controller, controller1);
            Assert.AreSame(controller1, controller2);
            mockUnderlyingFactory.Verify();
        }
        public void ResolvingFromMetadata_WrappedInSingletonDecorator_ResultsInTheSameSingletonInstanceAsANormalResolve()
        {
            // Arrange
            var container = ContainerFactory.New();

            container.Register<ICommandHandler<RealCommand>, RealCommandHandler>(Lifestyle.Singleton);
            container.RegisterDecorator(
                typeof(ICommandHandler<>), typeof(CommandHandlerDecorator<>), Lifestyle.Singleton);

            ICommandHandler<RealCommand> expectedHandler =
                container.GetInstance<ICommandHandler<RealCommand>>();

            // Act
            var service = container.GetInstance<MetadataWrapper<ICommandHandler<RealCommand>>>();

            ICommandHandler<RealCommand> actualHandler = service.Metadata.GetInstance();

            // Assert
            Assert.AreSame(expectedHandler, actualHandler);
        }
        public void Convert_IfWriteEntityReturnsNull_DoesNotPopulateOtherProperties()
        {
            // Arrange
            const string expectedPartitionKey = "PK";
            IConverter <TableEntity, PocoWithPartitionKeyAndOtherProperty> product =
                CreateProductUnderTest <PocoWithPartitionKeyAndOtherProperty>();
            TableEntity entity = new TableEntity
            {
                PartitionKey = expectedPartitionKey,
            };
            // TODO:
            //Assert.Null(entity.WriteEntity(operationContext: null)); // Guard
            // Act
            PocoWithPartitionKeyAndOtherProperty actual = product.Convert(entity);

            // Assert
            Assert.NotNull(actual);
            Assert.Null(actual.OtherProperty);
            Assert.AreSame(expectedPartitionKey, actual.PartitionKey);
        }
Example #23
0
        public void OnComponentRetrievedParams()
        {
            Assert.IsNotNull(_listener.RetrievedIdentity);
            Assert.AreEqual(_listener.RetrievedIdentity.Type, typeof(ISampleContract));
            Assert.IsNull(_listener.RetrievedIdentity.Name);

            Assert.IsNotNull(_listener.RetrievedComponentFactory);
            Assert.IsInstanceOfType(_listener.RetrievedComponentFactory, typeof(LocalComponentFactory));
            Assert.AreEqual(((LocalComponentFactory)_listener.RetrievedComponentFactory).TargetType, typeof(SampleComponentOne));

            Assert.IsNotNull(_listener.RetrievedComponentTargetType);
            Assert.AreEqual(_listener.RetrievedComponentTargetType, typeof(SampleComponentOne));

            Assert.IsNotNull(_listener.RetrievedComponentInstance);
            Assert.IsInstanceOfType(_listener.RetrievedComponentInstance, typeof(SampleComponentOne));

            Assert.IsNotNull(_listener.RetrievedOriginalInstance);
            Assert.IsInstanceOfType(_listener.RetrievedOriginalInstance, typeof(SampleComponentOne));
            Assert.AreSame(_listener.RetrievedComponentInstance, _listener.RetrievedOriginalInstance);
        }
Example #24
0
        public void RegisteredFactoryOverUnregisterd()
        {
            var instance = new Foo();

            // Act/Verify
            var instance1 = Container.Resolve(typeof(Foo));

            Container.RegisterFactory <Foo>((c, t, n) => instance);
            var instance2 = Container.Resolve(typeof(Foo));

            Assert.IsNotNull(instance1);
            Assert.IsNotNull(instance2);

            Assert.IsInstanceOfType(instance1, typeof(Foo));
            Assert.IsInstanceOfType(instance2, typeof(Foo));

            Assert.AreSame(instance, instance2);
            Assert.AreNotSame(instance1, instance);
            Assert.AreNotSame(instance1, instance2);
        }
Example #25
0
        public void OnResolvingExistsObject()
        {
            var container = MakeContainer();
            var data      = new List <string> {
                "hello world"
            };

            container.Instance("TestInstance", data);

            var isCall = false;

            container.OnResolving((bind, obj) =>
            {
                isCall = true;
                Assert.AreSame(data, obj);
                return(obj);
            });

            Assert.AreEqual(true, isCall);
        }
        public void Read_EntityWithHydraulicBoundaryLocationInCollector_CalculationHasAlreadyReadHydraulicBoundaryLocation()
        {
            // Setup
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 1.1, 2.2);
            var hydraulicLocationEntity   = new HydraulicLocationEntity();
            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                HydraulicLocationEntity = hydraulicLocationEntity
            };

            var collector = new ReadConversionCollector();

            collector.Read(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.AreSame(hydraulicBoundaryLocation, calculation.InputParameters.HydraulicBoundaryLocation);
        }
Example #27
0
        public void Create_Session_RetrieveNew_Success()
        {
            // Arrange
            newUser    = tu.CreateUserObject();
            newSession = tu.CreateSessionObject(newUser);
            var expected = newSession;

            using (_db = tu.CreateDataBaseContext())
            {
                // Act
                var response = ss.CreateSession(_db, newSession);
                _db.SaveChanges();

                //Assert
                var result = _db.Sessions.Find(newSession.Id);
                Assert.IsNotNull(response);
                Assert.IsNotNull(result);
                Assert.AreSame(result, expected);
            }
        }
Example #28
0
        public void BrowseResponsesSetsTheAnswerFromTheStoreInTheModel()
        {
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();
            var surveyAnswer          = new SurveyAnswer();

            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerBrowsingContext(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new SurveyAnswerBrowsingContext {
                PreviousId = string.Empty, NextId = string.Empty
            });
            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswer("tenant", "survey-slug", "answer id"))
            .Returns(surveyAnswer);

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, null, null))
            {
                var result = controller.BrowseResponses("tenant", "survey-slug", "answer id") as ViewResult;

                var model = result.ViewData.Model as TenantPageViewData <BrowseResponseModel>;
                Assert.AreSame(surveyAnswer, model.ContentModel.SurveyAnswer);
            }
        }
Example #29
0
        public void ManageabilityProviderIsProperlyRegistered()
        {
            ConfigurationElementManageabilityProviderAttribute selectedAttribute = null;

            Assembly assembly = typeof(RollingFlatFileTraceListenerDataManageabilityProvider).Assembly;

            foreach (ConfigurationElementManageabilityProviderAttribute providerAttribute
                     in assembly.GetCustomAttributes(typeof(ConfigurationElementManageabilityProviderAttribute), false))
            {
                if (providerAttribute.ManageabilityProviderType.Equals(typeof(RollingFlatFileTraceListenerDataManageabilityProvider)))
                {
                    selectedAttribute = providerAttribute;
                    break;
                }
            }

            Assert.IsNotNull(selectedAttribute);
            Assert.AreSame(typeof(LoggingSettingsManageabilityProvider), selectedAttribute.SectionManageabilityProviderType);
            Assert.AreSame(typeof(RollingFlatFileTraceListenerData), selectedAttribute.TargetType);
        }
Example #30
0
		public void Setup_Register_Factory_SetupPipeline()
		{
			var pipelineId = Guid.NewGuid().ToString();

			var handler = new SetupOutputHandler();

			var server = new ProcessingServer();
			server.SetupPipeline(pipelineId, c =>
			{
				c.Register(() =>
				{
					var pipeline = new EventPipeline();
					pipeline.AddHandler(handler);

					return pipeline;
				});
			});

			Assert.AreSame(handler, GetOutputHandlers(server, pipelineId).Single());
		}