Ejemplo n.º 1
0
        private static void HasNotChanged(Type type)
        {
            var projectResolver = new ProjectResolver();

            var typeLoader  = new ReflectionTypeLoader();
            var projectInfo = projectResolver.GetProjectInfo(type);

            var api = typeLoader.LoadApi(type);

            Directory.CreateDirectory(projectInfo.TestFolderPath);
            if (!projectResolver.ApiFileExists(projectInfo, type))
            {
                projectResolver.WriteApiToFile(projectInfo, type, api);
                return;
            }

            var existingApi = projectResolver.ReadApiFromFile(projectInfo, type);

            var compareStrategy = new BestGuessEndpointMatchingStrategy();
            var comparer        = new ApiComparer(compareStrategy);

            comparer.Compare(existingApi, api);

            // Nice to have:
            // Fields / Events / Delegates
            // Supporting constructor arguments on attributes
            // Multiple public types per file
            // custom struct as type
            // Re-generate the output file if there are changes to the API that aren't breaking
        }
Ejemplo n.º 2
0
        public void CanRoundtripDeserializeApi()
        {
            var resolver   = new ProjectResolver();
            var typeLoader = new ReflectionTypeLoader();
            var api        = typeLoader.LoadApi(typeof(TestApi));

            var serializedApi   = resolver.SerializeApi(api);
            var deserializedApi = resolver.DeserializeApi(serializedApi);

            Assert.Equal(api, deserializedApi);
            api.NestedElements.ForEach(x => Assert.NotNull(x.Parent));
            deserializedApi.NestedElements.ForEach(x => Assert.NotNull(x.Parent));
        }
        internal static MyType GetApi(Type type)
        {
            var typeLoader = new ReflectionTypeLoader();

            return(typeLoader.LoadApi(type));
        }