public void Init() { PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser)); var cache = p.GetStaticField("_expressionCache") as ConcurrentDictionary<string, IList<IIntellisenseResult>>; Assert.IsNotNull(cache); cache.Clear(); var cache2 = p.GetStaticField("_payloadCache") as ConcurrentDictionary<Tuple<string, string>, IList<IIntellisenseResult>>; Assert.IsNotNull(cache2); cache2.Clear(); Monitor.Enter(DataListSingletonTest.DataListSingletonTestGuard); var testEnvironmentModel = ResourceModelTest.CreateMockEnvironment(); _resourceModel = new ResourceModel(testEnvironmentModel.Object) { ResourceName = "test", ResourceType = ResourceType.Service, DataList = @" <DataList> <Scalar/> <Country/> <State /> <City> <Name/> <GeoLocation /> </City> </DataList> " }; IDataListViewModel setupDatalist = new DataListViewModel(); DataListSingleton.SetDataList(setupDatalist); DataListSingleton.ActiveDataList.InitializeDataListViewModel(_resourceModel); }
public void SystemStartAndShutdown() { //---- Ensure test data var entities = CreateTestEntities(); var groups = CreateTestGroups(); var memberships = Tools.CreateInMemoryMembershipTable(groups); var aces = CreateTestAces(); var storage = new DatabaseStorage { Aces = aces, Memberships = memberships, Entities = entities }; //---- Start the system Context.StartTheSystem(new MemoryDataProvider(storage), new DefaultMessageProvider()); var ctxAcc = new PrivateType(typeof(SecurityContext)); var killed = (bool)ctxAcc.GetStaticField("_killed"); Assert.IsFalse(killed); //---- Start the request context = new Context(TestUser.User1); //---- operation context.Security.HasPermission(entities.First().Value.Id, PermissionType.FullControl); //---- kill the system SecurityContext.Shutdown(); //---- check killed state killed = (bool)ctxAcc.GetStaticField("_killed"); Assert.IsTrue(killed); }
public void iiGetTSData_MyWork_IsEmpty() { // Arrange SetupShimsForSqlClient(); SetupShimsForSharePoint(); ShimTimesheetSettings.ConstructorSPWeb = (instance, __) => { instance.TimesheetFields = new ArrayList { FirstField }; }; ShimMyWorkReportData.AllInstances.ExecuteSqlString = (instance, _string) => { return(new DataTable()); }; ShimDataTable.AllInstances.PrimaryKeySetDataColumnArray = (_, __) => { }; // Act var result = (DataSet)PrivateType.InvokeStatic("iiGetTSData", new ShimSqlConnection().Instance, new ShimSPWeb().Instance, DummyString, Guid.Empty, new ShimMyWorkReportData().Instance, DummyString); // Assert Assert.IsNotNull(result); Assert.AreEqual(Convert.ToInt32(PrivateType.GetStaticField("myworktableid")), result.Tables.Count); }
public void FunctionConstructorTest() { Function func = new TestFunc(); PrivateObject prvt_obj_super = new PrivateObject(func, new PrivateType(typeof(Function))); PrivateType prvt_obj_sub = new PrivateType(typeof(TestFunc)); // フィールドの取得 int order = (int)prvt_obj_super.GetField("order"); int unknown = (int)prvt_obj_super.GetField("unknown"); int ORDER = (int)prvt_obj_sub.GetStaticField("ORDER"); int UNKNOWN = (int)prvt_obj_sub.GetStaticField("UNKNOWN"); // テスト Assert.AreEqual(ORDER, order); Assert.AreEqual(UNKNOWN, unknown); }
public void Reset() { var testSubject = new PrivateType(typeof(EventManager)); // done in Initialize():> WeakEventManager.Reset(); Assert.That(EventManager.Count, Is.EqualTo(0)); Assert.That((DateTime)testSubject.GetStaticField("s_LastCollect"), Is.EqualTo(DateTime.MinValue)); Assert.That(EventManager.StatisticsːRaiseːInvocationCount, Is.EqualTo(0)); }
public void TestCtorDefaultStageSize() { var conn = MockRepository.GenerateStub <IDataContextServices>(); var provider = new DataproviderFactory(conn); var stage = new ImportStageModel(provider); var p = new PrivateType(typeof(ImportStageModel)); var expected = p.GetStaticField("DefaultStageSize"); var actual = stage.StageSize; Assert.AreEqual(expected, actual); }
public string ParseBasename(string remainingPath) { var currentDirectoryIdentifier = ((string)_pathUtils.GetStaticField("CurrentDirectoryIdentifier")); return(!String.IsNullOrEmpty(remainingPath) ? remainingPath != currentDirectoryIdentifier ? ((string)_pathUtils.InvokeStatic( "GetFileNameWithoutExtension", new object[] { remainingPath, PathSeparator })) : currentDirectoryIdentifier : null); }
public void FunctionUnknownTest() { Function func = new TestFunc(); PrivateType prvt_obj = new PrivateType(typeof(TestFunc)); // フィールドの取得 int unknown = func.Unknown; int UNKNOWN = (int)prvt_obj.GetStaticField("UNKNOWN"); // テスト Assert.AreEqual(UNKNOWN, unknown); }
public void FunctionOrderTest() { Function func = new TestFunc(); PrivateType prvt_obj = new PrivateType(typeof(TestFunc)); // フィールドの取得 int order = func.Order; int ORDER = (int)prvt_obj.GetStaticField("ORDER"); // テスト Assert.AreEqual(ORDER, order); }
public void DefaultConstructorTestMethod() { //arrange NHetmanow nHetmanowTesting = new NHetmanow(); PrivateObject nHetmanow = new PrivateObject(nHetmanowTesting); PrivateType nHetmanowClass = new PrivateType(typeof(NHetmanow)); //act var liczbaHetmanow = nHetmanowClass.GetStaticField("_liczbaHetmanow"); var domyslnyRozmiarPopulacji = nHetmanow.GetProperty("RozmiarPopulacji"); var domyslnePrawdopodobienstwoMutacji = nHetmanow.GetProperty("PrawdopodobienstwoMutacji"); //assert Assert.AreEqual(8, liczbaHetmanow); Assert.AreEqual(10, domyslnyRozmiarPopulacji); Assert.AreEqual(0.01f, domyslnePrawdopodobienstwoMutacji); }
public void ContentNaming_FromDisplayName() { var providers = new[] { (ContentNamingProvider) new CharReplacementContentNamingProvider(), (ContentNamingProvider) new Underscore5FContentNamingProvider() }; var contentNamingProviderAcc = new PrivateType(typeof(ContentNamingProvider)); var originalProvider = contentNamingProviderAcc.GetStaticField("__instance"); try { foreach (var provider in providers) { contentNamingProviderAcc.SetStaticField("__instance", provider); var providerName = provider.GetType().Name; Assert.AreEqual("árvíztűrőtükörfúrógép", ContentNamingProvider.GetNameFromDisplayName("árvíztűrőtükörfúrógép")); Assert.AreEqual("ÁRVÍZTŰRŐTÜKÖRFÚRÓGÉP", ContentNamingProvider.GetNameFromDisplayName("ÁRVÍZTŰRŐTÜKÖRFÚRÓGÉP")); Assert.AreEqual("ÁrvíztűrőTükörfúrógép", ContentNamingProvider.GetNameFromDisplayName("ÁrvíztűrőTükörfúrógép")); Assert.AreEqual("árvíztűrőtükörfúrógép.txt", ContentNamingProvider.GetNameFromDisplayName("árvíztűrőtükörfúrógép.txt")); Assert.AreEqual("árvíztűrőtükörfúrógép.doc.txt", ContentNamingProvider.GetNameFromDisplayName("árvíztűrőtükörfúrógép.txt", "árvíztűrőtükörfúrógép.doc")); Assert.AreEqual("árvíztűrőtükörfúrógép.doc.txt", ContentNamingProvider.GetNameFromDisplayName(".txt", "árvíztűrőtükörfúrógép.doc")); var name = ContentNamingProvider.GetNameFromDisplayName("!*_~@#$%a^&()b{}+\"'|:<>?c/.,"); if (providerName == typeof(CharReplacementContentNamingProvider).Name) { Assert.AreEqual("!-_-a-()b-c", name); } else if (providerName == typeof(Underscore5FContentNamingProvider).Name) { Assert.AreEqual("!_2a_5f_7e_40_23_24_25a_5e_26()b_7b_7d_2b_22_27_7c_3a_3c_3e_3fc_2f._2c", name); } else { Assert.Inconclusive("Unknown ContentNamingProvider: " + providerName); } } } finally { contentNamingProviderAcc.SetStaticField("__instance", originalProvider); } }
public void CalculateCosineCoefficients_Test() { PrivateType pt = new PrivateType(typeof(JpegImage)); JpegImage ji = new JpegImage(new Bitmap(200, 100), 100, 4); //Constructor calls calcCosineCoef float[,] CosCoef = (float[,])pt.GetStaticField("CosinesCoefficients"); float[,] ExpectedCosCoef = new float[8, 8] { {1f, 0.980785251f, 0.9238795f, 0.8314696f, 0.707106769f, 0.555570245f, 0.382683426f, 0.195090324f}, {1f, 0.8314696f, 0.382683426f, -0.195090324f, -0.707106769f, -0.980785251f, -0.9238795f, -0.555570245f}, {1f, 0.555570245f, -0.382683426f, -0.980785251f, -0.707106769f, 0.195090324f, 0.923879504f, 0.831469595f}, {1f, 0.195090324f, -0.923879504f, -0.555570245f, 0.707106769f, 0.831469595f, -0.382683426f, -0.980785251f}, {1f, -0.195090324f, -0.923879504f, 0.555570245f, 0.707106769f, -0.831469595f, -0.382683426f, 0.980785251f}, {1f, -0.555570245f, -0.382683426f, 0.980785251f, -0.707106769f, -0.195090324f, 0.923879504f, -0.831469595f}, {1f, -0.831469595f, 0.382683426f, 0.195090324f, -0.707106769f, 0.980785251f, -0.923879504f, 0.555570245f}, {1f, -0.980785251f, 0.923879504f, -0.831469595f, 0.707106769f, -0.555570245f, 0.382683426f, -0.195090324f}, }; Assert.AreEqual(ExpectedCosCoef, CosCoef); }
public void Test1() { var target = new PrivateType(typeof(SettingsHost)); var fullpath = (string)target.GetStaticField("fullpath"); if (File.Exists(fullpath) == true) { File.Delete(fullpath); } SettingsHost.Init(); var vm = new InformationWindowViewModel(); vm.Setting.Topmost = true; //ここでプロパティを書き換え Console.WriteLine(vm.Setting.Topmost); SettingsHost.SaveFile(); var wsetting = SettingsHost.Instance <InformationWindowSetting>(); Console.WriteLine(wsetting.Topmost); }
public void Dev2LanuageParser_Parse_IValid_ExpectNoCache() { //------------Setup for test-------------------------- const string dl = "<ADL><rec><val/></rec></ADL>"; const string payload = "[[rec().val]]"; PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser)); var cache = p.GetStaticField("_expressionCache") as ConcurrentDictionary<string, IList<IIntellisenseResult>>; Assert.IsNotNull(cache); cache.Clear(); Assert.AreEqual(cache.Count, 0); ParseDataLanguageForIntellisense(payload, dl, true, false); Assert.IsNotNull(cache); Assert.AreEqual(cache.Count, 0); //------------Execute Test--------------------------- //------------Assert Results------------------------- }
public void Dev2LanuageParser_Parse_Valid_ExpectCache() { //------------Setup for test-------------------------- PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser)); var cache = p.GetStaticField("_payloadCache") as ConcurrentDictionary<Tuple<string, string>, IList<IIntellisenseResult>>; if(cache != null) { cache.Clear(); } const string dl = "<ADL><rec><val/></rec></ADL>"; const string payload = "[[rec().val]]"; var dev2LanuageParser = new Dev2DataLanguageParser(); IList<IIntellisenseResult> results = ParseDataLanguageForIntellisense(payload, dl, true, false); Assert.IsNotNull(cache); Assert.AreEqual(cache.Count,1); //------------Execute Test--------------------------- //------------Assert Results------------------------- }
public void Dev2LanuageParser_ParseExpressionIntoParts_WhenInValid_ExpectNoCache() { //------------Setup for test-------------------------- var dev2LanuageParser = new Dev2DataLanguageParser(); PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser)); var cache = p.GetStaticField("_payloadCache") as ConcurrentDictionary<Tuple<string, string>, IList<IIntellisenseResult>>; Assert.IsNotNull(cache); cache.Clear(); Assert.AreEqual(cache.Count, 0); const string data = @"[[rec(*123).a]]"; const string dl = "<DataList><rec><a/></rec></DataList>"; var compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; var dlID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), string.Empty.ToStringBuilder(), dl.ToStringBuilder(), out errors); var bdl = compiler.FetchBinaryDataList(dlID, out errors); var intillisenseParts = bdl.FetchIntellisenseParts(); //------------Execute Test--------------------------- dev2LanuageParser.ParseExpressionIntoParts(data, intillisenseParts); //------------Assert Results------------------------- Assert.IsNotNull(cache); Assert.AreEqual(cache.Count, 0); }
public static void StartTests(TestContext context) { // prevent accessing the database _adsyncAvailableBackup = SnMaintenanceAcc.GetStaticField("_adsyncAvailable"); SnMaintenanceAcc.SetStaticField("_adsyncAvailable", false); }
public static T GetStaticMemberValue <T>(this Type type, string memberName) { PrivateType privateType = new PrivateType(type); return((T)privateType.GetStaticField(memberName, BindingFlags.NonPublic | BindingFlags.Static)); }
internal T GetStaticField <T>(string name) { return((T)_wrappedType.GetStaticField(name)); }