public void MapOfFieldWithEventName_RendersTwoItem()
        {
            using var restorePoint = new GraphQLProviderRestorePoint();
            SchemaSubscriptionEventMap.ClearCache();

            var schema = new TestServerBuilder <EventMapSchema>()
                         .AddSubscriptionServer()
                         .AddGraphController <OneFieldMapWithEventNameController>()
                         .Build()
                         .Schema;

            var map      = SchemaSubscriptionEventMap.CreateEventMap(schema);
            var pathName = "[subscription]/OneFieldMapWithEventName/TestActionMethod";

            var pathEventName = new SubscriptionEventName(typeof(EventMapSchema), pathName);
            var eventName     = new SubscriptionEventName(typeof(EventMapSchema), "shortTestName");

            Assert.AreEqual(2, map.Count);
            Assert.IsTrue(map.ContainsKey(eventName));
            Assert.IsNotNull(map[eventName]);
            Assert.AreEqual(pathName, map[eventName].Path);

            Assert.IsTrue(map.ContainsKey(eventName));
            Assert.IsNotNull(map[eventName]);
            Assert.AreEqual(pathName, map[eventName].Path);

            // ensure both items reference the same object
            Assert.AreSame(map[pathEventName], map[eventName]);
        }
        public void DuplicateEventName_ThrowsException()
        {
            using var restorePoint = new GraphQLProviderRestorePoint();
            SchemaSubscriptionEventMap.ClearCache();

            var schema = new TestServerBuilder <EventMapSchema>()
                         .AddSubscriptionServer()
                         .AddGraphController <DuplicateEventNameController>()
                         .Build()
                         .Schema;

            Assert.Throws <DuplicateNameException>(() =>
            {
                var map = SchemaSubscriptionEventMap.CreateEventMap(schema);
            });
        }
        public void RetrieveFieldPathByName_YieldsCorrectPath()
        {
            using var restorePoint = new GraphQLProviderRestorePoint();
            SchemaSubscriptionEventMap.ClearCache();

            var schema = new TestServerBuilder <EventMapSchema>()
                         .AddSubscriptionServer()
                         .AddGraphController <OneFieldMapController>()
                         .Build()
                         .Schema;

            var map       = SchemaSubscriptionEventMap.CreateEventMap(schema);
            var pathName  = "[subscription]/OneFieldMap/TestActionMethod";
            var eventName = new SubscriptionEventName(typeof(EventMapSchema), pathName);

            var fieldPath = schema.RetrieveSubscriptionFieldPath(eventName);

            Assert.IsNotNull(fieldPath);
            Assert.AreEqual(pathName, fieldPath.Path);
        }
        public void MapOfFieldWithNoEventName_RendersOneItem()
        {
            using var restorePoint = new GraphQLProviderRestorePoint();
            SchemaSubscriptionEventMap.ClearCache();

            var schema = new TestServerBuilder <EventMapSchema>()
                         .AddSubscriptionServer()
                         .AddGraphController <OneFieldMapController>()
                         .Build()
                         .Schema;

            var map       = SchemaSubscriptionEventMap.CreateEventMap(schema);
            var pathName  = "[subscription]/OneFieldMap/TestActionMethod";
            var eventName = new SubscriptionEventName(typeof(EventMapSchema), pathName);

            Assert.AreEqual(1, map.Count);
            Assert.IsTrue(map.ContainsKey(eventName));
            Assert.IsNotNull(map[eventName]);
            Assert.AreEqual(pathName, map[eventName].Path);
        }