public void BitmaskSeverity () { Bitmask<Severity> x = new Bitmask<Severity> (); Assert.IsFalse (x.Get (Severity.Audit), "Empty/Audit"); Assert.AreEqual (0, x.GetHashCode (), "Empty/GetHashCode"); Assert.AreEqual ("0", x.ToString (), "Empty/ToString"); x.Set (Severity.Audit); Assert.IsTrue (x.Get (Severity.Audit), "Set/Audit"); Assert.AreEqual (16, x.GetHashCode (), "GetHashCode"); Assert.AreEqual ("10000", x.ToString (), "ToString"); Assert.IsTrue (x.Equals (x), "Equals(self)"); Assert.IsTrue (x.Equals ((object) x), "Equals((object)self)"); Assert.IsFalse (x.Equals (Severity.Audit), "Equals"); x.Clear (Severity.Audit); Assert.IsFalse (x.Get (Severity.Audit), "Clear/Audit"); }
public void BitmaskSeverity() { Bitmask <Severity> x = new Bitmask <Severity> (); Assert.IsFalse(x.Get(Severity.Audit), "Empty/Audit"); Assert.AreEqual(0, x.GetHashCode(), "Empty/GetHashCode"); Assert.AreEqual("0", x.ToString(), "Empty/ToString"); x.Set(Severity.Audit); Assert.IsTrue(x.Get(Severity.Audit), "Set/Audit"); Assert.AreEqual(16, x.GetHashCode(), "GetHashCode"); Assert.AreEqual("10000", x.ToString(), "ToString"); Assert.IsTrue(x.Equals(x), "Equals(self)"); Assert.IsTrue(x.Equals((object)x), "Equals((object)self)"); Assert.IsFalse(x.Equals(Severity.Audit), "Equals"); x.Clear(Severity.Audit); Assert.IsFalse(x.Get(Severity.Audit), "Clear/Audit"); }
private void CheckSatelliteResource(EmbeddedResource mainResource, EmbeddedResource satelliteResource, IMetadataTokenProvider satelliteAssembly) { using (Stream resourceStream = satelliteResource.GetResourceStream()) using (ResourceSet resourceSet = new ResourceSet(resourceStream)) { foreach (DictionaryEntry entry in resourceSet) { string resourceName = (string)entry.Key; object satelliteValue = entry.Value; object mainValue; if (!mainAssemblyResourceCache.TryGetMainResource(mainResource, resourceName, out mainValue)) { string msg = String.Format(CultureInfo.InvariantCulture, "The resource {0} in the file {1} exist in the satellite assembly but not in the main assembly", resourceName, satelliteResource.Name); Runner.Report(satelliteAssembly, Severity.Low, Confidence.High, msg); continue; } Type satelliteType = satelliteValue.GetType(); Type mainType = mainValue.GetType(); if (!satelliteType.Equals(mainType)) { string msg = String.Format(CultureInfo.InvariantCulture, "The resource {0} in the file {1} is of type {2} in the satellite assembly but of type {3} in the main assembly", resourceName, satelliteResource.Name, satelliteType, mainType); Runner.Report(satelliteAssembly, Severity.High, Confidence.High, msg); continue; } if (satelliteType.Equals(typeof(string))) { Bitmask <int> mainParameters = GetStringFormatExpectedParameters((string)mainValue); Bitmask <int> satelliteParameters = GetStringFormatExpectedParameters((string)satelliteValue); if (!mainParameters.Equals(satelliteParameters)) { string msg = String.Format(CultureInfo.InvariantCulture, "The string resource {0} in the file {1} does not use the same string format parameters in the satellite and main assemblies", resourceName, satelliteResource.Name); Runner.Report(satelliteAssembly, Severity.High, Confidence.Normal, msg); } } } } }