{"id":21034528,"url":"https://github.com/budougumi0617/testable","last_synced_at":"2025-06-11T17:32:08.913Z","repository":{"id":71447145,"uuid":"96116417","full_name":"budougumi0617/Testable","owner":"budougumi0617","description":"Allows test code to call methods and properties even if non public.","archived":false,"fork":false,"pushed_at":"2017-10-13T07:21:18.000Z","size":49,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-30T08:33:46.650Z","etag":null,"topics":["csharp","dotnet-standard","nuget-package","unittest"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/budougumi0617.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-07-03T13:55:51.000Z","updated_at":"2017-08-18T06:56:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"f496f328-f7f3-4f58-b425-400c78afc588","html_url":"https://github.com/budougumi0617/Testable","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/budougumi0617/Testable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budougumi0617%2FTestable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budougumi0617%2FTestable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budougumi0617%2FTestable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budougumi0617%2FTestable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/budougumi0617","download_url":"https://codeload.github.com/budougumi0617/Testable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budougumi0617%2FTestable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259308157,"owners_count":22837974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet-standard","nuget-package","unittest"],"created_at":"2024-11-19T13:07:27.953Z","updated_at":"2025-06-11T17:32:08.908Z","avatar_url":"https://github.com/budougumi0617.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testable\n[![NuGet version](https://badge.fury.io/nu/budougumi0617.Testable.svg)](https://badge.fury.io/nu/budougumi0617.Testable)\n[![Build status](https://ci.appveyor.com/api/projects/status/nv8feqr5attxrx5j?svg=true)](https://ci.appveyor.com/project/budougumi0617/testable)\n[![codecov](https://codecov.io/gh/budougumi0617/Testable/branch/master/graph/badge.svg)](https://codecov.io/gh/budougumi0617/Testable)\n\n\n# Introduction\n\nAllows test code to call fields, methods, ~~and properties~~ even if non public, like a `PrivateObject`.\n\n[Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject](https://msdn.microsoft.com/ja-jp/library/microsoft.visualstudio.testtools.unittesting.privateobject.aspx)\n\nAnd, you can call static fiealds like a `PrivateType`. but, you do not need create wrapper instance if you want to call static members. \n\n[Microsoft.VisualStudio.TestTools.UnitTesting.PrivateType](https://msdn.microsoft.com/ja-jp/library/microsoft.visualstudio.testtools.unittesting.privatetype.aspx)\n\n# How to use\n\nEasy sample is below. If you want to read more example, please check [test codes](./Testable.Tests/PrivateObjectTests.cs).\n\n```cs\n public class TargetClass\n {\n    private int privateInt;\n    private static privateStaticInt;\n    static string throughString(string s)\n    {\n        return s;\n    }\n }\n\n---\n\nPrivateObject pivateObject = new PrivateObject(new TargetClass() as Object);\nint privateIntField = Convert.ToInt32(po.GetField(\"privateInt\"));\npo.SetField(\"privateInt\", 1000);\n\n\n// Access private static field by extension methods.\n\ntypeof(TargetClass).SetStaticField(\"privateStaticInt\", 100);\nint privateStaticIntField = Convert.ToInt32(typeof(TargetClass).GetStaticField(\"privateStaticInt\"));\n\ntypeof(TargetClass).SetStaticField(\"privateStaticMethod\", 100);\n\n// Call private static method by extension methods.\n\nvar argTypes = new Type[] { typeof(string) };\nvar args = new Object[] { \"arguments\" };\nvar returnString = (string)typeof(TargetClass).InvokeStatic(\"throughString\", argTypes, args); \n```\n\n# Features\n\n## `Testable.PrivateObject`\n\n|Method|Description|\n|---|---|\n|`PrivateObject(Object)`|Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.|\n|`GetField(String)`|Gets a value from a named field, based on the name.|\n|`SetField(String, Object)`|Sets a value for the field of the wrapped object, identified by name.|\n|`Invoke(String, Type[], Object[])`|Used to access the methods of the private object.|\n|???|Now implementing...|\n\n## `Testable.PrivateStaticAccessor`\n|Method|Description|\n|---|---|\n|`GetStaticField(this Type, string)`|Gets a value from a named static field, based on the name.|\n|`SetStaticField(this Type, string, Object)`|Sets a value for a named static field, identified by name.|\n|`InvokeStatic(this Type, string, Type[], Object[])`|Invokes static method.|\n|???|Now implementing...|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbudougumi0617%2Ftestable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbudougumi0617%2Ftestable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbudougumi0617%2Ftestable/lists"}