public void testParseGraduationDate() { String sXML = "<StudentPersonal RefId='12345678901234567890'>" + " <GradYear Type='Actual'>2005</GradYear>" + "</StudentPersonal>"; StudentPersonal sp = (StudentPersonal)parseSIF15r1XML(sXML); sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11); Assertion.AssertNotNull(sp); PartialDateType gd = sp.GraduationDate; Assertion.AssertNotNull("Actual Grad Year", gd); Assertion.AssertEquals("Actual Grad Year", 2005, (int)gd.Year); Adk.SifVersion = SifVersion.SIF15r1; sp = new StudentPersonal(); sp.SetElementOrAttribute("GradYear[@Type='Actual']", "2054"); gd = sp.GraduationDate; Assertion.AssertNotNull("Actual Grad Year", gd); Assertion.AssertNotNull("GraduationDate/getYear()", gd.Year); Assertion.AssertEquals("Actual Grad Year", 2054, gd.Year.Value); Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Actual']"); Assertion.AssertNotNull("Actual Grad Year", gradValue); PartialDateType pdt = (PartialDateType)gradValue; Assertion.AssertEquals("Actual Grad Year", 2054, pdt.Year.Value); }
public void TestAddRoleToSPSiteNoAdd() { String addPerms = ""; string result = result = RunBuild(String.Format(CultureInfo.InvariantCulture, _xmlProjectTemplate, _newSPSiteUrl, "true", _testRoleName, _roleDescription, _baseRoleName, addPerms)); SPSite site = new SPSite(_newSPSiteUrl); SPRole newRole = site.RootWeb.Roles[_testRoleName]; Assertion.AssertNotNull("New Role is null!", newRole); // Construct the rights the role should have for comparison. SPRights rights = site.RootWeb.Roles[_baseRoleName].PermissionMask; Assertion.AssertEquals("permissions were not correctly modified.", 0, rights.CompareTo(newRole.PermissionMask)); }
/// <summary> /// Adds a new attribute to this directive. /// </summary> /// <param name="attribute">The attribute to add.</param> /// <returns>A new instance of <see cref="IT4DirectiveAttribute"/>, representing <paramref name="attribute"/> in the T4 file.</returns> public IT4DirectiveAttribute AddAttribute(IT4DirectiveAttribute attribute) { if (attribute == null) { throw new ArgumentNullException("attribute"); } using (WriteLockCookie.Create(IsPhysical())) { ITreeNode lastNode = LastChild; Assertion.AssertNotNull(lastNode, "lastNode != null"); ITreeNode anchor = IsEndNode(lastNode) ? lastNode.PrevSibling : lastNode; Assertion.AssertNotNull(anchor, "anchor != null"); bool addSpaceAfter = anchor.GetTokenType() == T4TokenNodeTypes.Space; bool addSpaceBefore = !addSpaceAfter; if (addSpaceBefore) { anchor = ModificationUtil.AddChildAfter(anchor, T4TokenNodeTypes.Space.CreateLeafElement()); } IT4DirectiveAttribute result = ModificationUtil.AddChildAfter(anchor, attribute); if (addSpaceAfter) { ModificationUtil.AddChildAfter(result, T4TokenNodeTypes.Space.CreateLeafElement()); } return(result); } }
public void TestOtherIdMappings() { String otherIdMapping = "<agent id=\"Repro\" sifVersion=\"2.0\">" + " <mappings id=\"Default\">" + " <object object='StudentPersonal'>" + " <field direction='inbound' name='FIELD1'><otherid type='ZZ' prefix='FIELD1:'/></field>" + " <field direction='outbound' name='FIELD1'>OtherIdList/OtherId[@Type='ZZ'+]=FIELD1:$(FIELD1)</field>" + " <field direction='inbound' name='FIELD2'><otherid type='ZZ' prefix='FIELD2:'/></field>" + " <field direction='outbound' name='FIELD2'>OtherIdList/OtherId[@Type='ZZ'+]=FIELD2:$(FIELD2)</field>" + " </object>" + " </mappings>" + "</agent>"; Dictionary <String, String> sourceMap = new Dictionary <String, String>(); sourceMap.Add("FIELD1", "1234"); sourceMap.Add("FIELD2", "5678"); StringMapAdaptor sma = new StringMapAdaptor(sourceMap); StudentPersonal sp = mapToStudentPersonal(sma, otherIdMapping, null); Assertion.AssertNotNull("Student should not be null", sp); IDictionary destinationMap = doInboundMapping(otherIdMapping, sp); assertMapsAreEqual(sourceMap, destinationMap); }
private static ILexer CreateLexer([NotNull] IPsiSourceFile includeSourceFile) { LanguageService languageService = T4Language.Instance.LanguageService(); Assertion.AssertNotNull(languageService, "languageService != null"); return(languageService.GetPrimaryLexerFactory().CreateLexer(includeSourceFile.Document.Buffer)); }
protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) { Action <ITextControl> action = null; if ((myMatch & MethodSignatureMatch.IncorrectStaticModifier) == MethodSignatureMatch.IncorrectStaticModifier && myExpectedMethodSignature.IsStatic.HasValue) { myMethodDeclaration.SetStatic(myExpectedMethodSignature.IsStatic.Value); } if ((myMatch & MethodSignatureMatch.IncorrectParameters) == MethodSignatureMatch.IncorrectParameters) { action = ChangeParameters(solution); } if ((myMatch & MethodSignatureMatch.IncorrectReturnType) == MethodSignatureMatch.IncorrectReturnType) { var element = myMethodDeclaration.DeclaredElement; Assertion.AssertNotNull(element, "element != null"); var language = myMethodDeclaration.Language; var changeTypeHelper = LanguageManager.Instance.GetService <IChangeTypeHelper>(language); changeTypeHelper.ChangeType(myExpectedMethodSignature.ReturnType, element); } if ((myMatch & MethodSignatureMatch.IncorrectTypeParameters) == MethodSignatureMatch.IncorrectTypeParameters) { // There are no generic Unity methods, so just remove any that are already there myMethodDeclaration.SetTypeParameterList(null); } return(action); }
private void OpenChameleon() { Assertion.Assert(!myOpened, "The condition (!myOpened) is false."); AssertSingleChild(); IClosedChameleonBody closedChameleon = null; for (var child = firstChild; child != null; child = child.nextSibling) { closedChameleon = child as IClosedChameleonBody; if (closedChameleon != null) { break; } } Assertion.AssertNotNull(closedChameleon, "closedChameleon != null"); var openChameleon = closedChameleon.Parse(parser => { var yamlParser = (IYamlParser)parser; return(yamlParser.ParseRootBlockNode()); }); // Need to do this outside assertion check because it will calculate cached offsets for children var newTextLength = openChameleon.GetTextLength(); Assertion.Assert(closedChameleon.GetTextLength() == newTextLength, "Chameleon length differ after opening! {0} {1} {2}", closedChameleon.GetTextLength(), newTextLength, GetSourceFile()?.DisplayName ?? "unknown file"); DeleteChildRange(firstChild, lastChild); OpenChameleonFrom(openChameleon); }
public void testSchoolCourseInfo() { IDictionary values = new Hashtable(); values.Add("CREDVALUE", "0"); values.Add("MAXCREDITS", "1"); StringMapAdaptor sma = new StringMapAdaptor(values); SchoolCourseInfo sc = new SchoolCourseInfo(); sc.SchoolYear = 1999; Mappings m = fCfg.Mappings.GetMappings("Default").Select(null, null, null); m.MapOutbound(sma, sc, SifVersion.SIF15r1); Console.WriteLine(sc.ToXml()); Element e = sc.GetElementOrAttribute("CourseCredits[@Code='01']"); Assertion.AssertNotNull("credits", e); Assertion.AssertEquals("credits", "0", e.TextValue); e = sc.GetElementOrAttribute("CourseCredits[@Code='02']"); Assertion.AssertNotNull("maxcredits", e); Assertion.AssertEquals("maxcredits", "1", e.TextValue); }
private static FileSystemPath GetBasePathBeforeMapping(IQualifiableReference pathReference) { IQualifier qualifier = pathReference.GetQualifier(); if (qualifier == null) { IProjectFile file = pathReference.GetTreeNode().GetSourceFile().ToProjectFile(); Assertion.AssertNotNull(file, "file == null"); return(file.Location.Directory); } var reference = qualifier as IReference; if (reference != null) { ResolveResultWithInfo resolveResultWithInfo = (reference).Resolve(); var pathDeclaredElement = resolveResultWithInfo.DeclaredElement as IPathDeclaredElement; if (pathDeclaredElement == null) { return(FileSystemPath.Empty); } return(pathDeclaredElement.Path); } var pathQualifier = qualifier as IPathQualifier; if (pathQualifier != null) { return(pathQualifier.Path); } return(FileSystemPath.Empty); }
public List <UnityType> LoadTypes(Version currentVersion) { var types = new List <UnityType>(); var ns = GetType().Namespace; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ns + @".api.xml")) { if (stream != null) { var document = new XmlDocument(); document.Load(stream); var apiNode = document.DocumentElement?.SelectSingleNode("/api"); Assertion.AssertNotNull(apiNode, "apiNode != null"); var minimumVersion = apiNode.Attributes?["minimumVersion"]?.Value; var maximumVersion = apiNode.Attributes?["maximumVersion"]?.Value; Assertion.Assert(minimumVersion != null && maximumVersion != null, "minimumVersion != null && maximumVersion != null"); var normaliser = new VersionNormaliser(Version.Parse(minimumVersion), Version.Parse(maximumVersion), currentVersion); var nodes = document.DocumentElement?.SelectNodes(@"/api/type"); Assertion.AssertNotNull(nodes, "nodes != null"); foreach (XmlNode type in nodes) { types.Add(CreateUnityType(type, normaliser)); } } } return(types); }
private bool ReferenceModuleImpl([NotNull] IPsiModule module, [NotNull] IPsiModule moduleToReference, [CanBeNull] string ns) { if (!CanReferenceModule(module, moduleToReference)) { return(false); } var t4PsiModule = (T4PsiModule)module; var assembly = (IAssembly)moduleToReference.ContainingProjectModule; Assertion.AssertNotNull(assembly, "assembly != null"); var t4File = t4PsiModule.SourceFile.GetTheOnlyPsiFile(T4Language.Instance) as IT4File; if (t4File == null) { return(false); } Action action = () => { // add assembly directive t4File.AddDirective(_directiveInfoManager.Assembly.CreateDirective(assembly.FullAssemblyName), _directiveInfoManager); // add import directive if necessary if (!String.IsNullOrEmpty(ns) && !t4File.GetDirectives(_directiveInfoManager.Import).Any(d => String.Equals(ns, d.GetAttributeValue(_directiveInfoManager.Import.NamespaceAttribute.Name), StringComparison.Ordinal))) { t4File.AddDirective(_directiveInfoManager.Import.CreateDirective(ns), _directiveInfoManager); } }; return(ExecuteTransaction(module, action)); }
private void assertAddressWithCountry(AddressList list, String expectedCountryCode) { Assertion.AssertNotNull("AddressList is null", list); Assertion.AssertEquals("Not one address in list", 1, list.Count); assertCountry(list.ItemAt(0), expectedCountryCode); }
public void ZipFileFindEntriesLongComment() { string tempFile = null; try { tempFile = Path.GetTempPath(); } catch (SecurityException) { } Assertion.AssertNotNull("No permission to execute this test?", tempFile); if (tempFile != null) { tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); string longComment = new String('A', 65535); MakeZipFile(tempFile, "", 1, 1, longComment); ZipFile zipFile = new ZipFile(tempFile); foreach (ZipEntry e in zipFile) { Stream instream = zipFile.GetInputStream(e); CheckKnownEntry(instream, 1); } zipFile.Close(); File.Delete(tempFile); } }
public void ZipFileRoundTrip() { string tempFile = null; try { tempFile = Path.GetTempPath(); } catch (SecurityException) { } Assertion.AssertNotNull("No permission to execute this test?", tempFile); if (tempFile != null) { tempFile = Path.Combine(tempFile, "SharpZipTest.Zip"); MakeZipFile(tempFile, "", 10, 1024, ""); ZipFile zipFile = new ZipFile(tempFile); foreach (ZipEntry e in zipFile) { Stream instream = zipFile.GetInputStream(e); CheckKnownEntry(instream, 1024); } zipFile.Close(); File.Delete(tempFile); } }
public static void SpecialInvoke(SimulationDataReadyHandler e) { if (e is null) { Log.Exception(new ArgumentNullException("e")); return; } Assertion.AssertNotNull(e); Log.Info($"invoking LoadingManager.m_SimulationDataReady()", copyToGameLog: true); Log.Flush(); sw_total.Reset(); sw_total.Start(); foreach (SimulationDataReadyHandler @delegate in e.GetInvocationList()) { string name = @delegate.Method.FullDescription(); Log.Info($"invoking " + name, copyToGameLog: true); sw.Reset(); sw.Start(); try { @delegate(); sw.Stop(); Log.Info($"{name} successful! " + $"duration = {sw.ElapsedMilliseconds:#,0}ms", copyToGameLog: true); } catch (Exception ex) { Log.Exception(ex); } } sw_total.Stop(); Log.Info($"LoadingManager.m_SimulationDataReady() successful! " + $"total duration = {sw_total.ElapsedMilliseconds:#,0}ms", copyToGameLog: true); Log.Flush(); }
public void SDOParse() { // Create a StudentPersonal StudentPersonal sp = ObjectCreator.CreateStudentPersonal(); // Test changing the name sp.Name = new Name(NameType.BIRTH, "STUDENT", "JOE"); sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF15r1); // Test to ensure that Email is not a child of StudentPersonal Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count); Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList); Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0); sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF20); // Test to ensure that Email is not a child of StudentPersonal Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count); Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList); Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0); sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF11); // Test to ensure that Email is not a child of StudentPersonal Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count); Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList); Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0); sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF22); // Test to ensure that Email is not a child of StudentPersonal Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count); Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList); Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0); }
public UnityTypes LoadTypes() { var types = new List <UnityType>(); var ns = GetType().Namespace; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ns + @".api.xml")) { Assertion.AssertNotNull(stream, "stream != null"); var document = new XmlDocument(); document.Load(stream); var apiNode = document.DocumentElement?.SelectSingleNode("/api"); Assertion.AssertNotNull(apiNode, "apiNode != null"); var minimumVersion = apiNode.Attributes?["minimumVersion"]?.Value; var maximumVersion = apiNode.Attributes?["maximumVersion"]?.Value; Assertion.Assert(minimumVersion != null && maximumVersion != null, "minimumVersion != null && maximumVersion != null"); var nodes = document.DocumentElement?.SelectNodes(@"/api/type"); Assertion.AssertNotNull(nodes, "nodes != null"); foreach (XmlNode type in nodes) { types.Add(CreateUnityType(type, minimumVersion, maximumVersion)); } return(new UnityTypes(types, GetInternedVersion(minimumVersion), GetInternedVersion(maximumVersion))); } }
public void TestRemoveBidirectionalRelation() { TableNode tn; ColumnNode cn; // Returns the Orders table node PrepareEmployeeOrder(out tn, out cn); Assertion.Assert(!cn.Column.IsMapped); Assertion.Assert(!cn.Column.IsMapped); NDOTreeNode treeNode = (NDOTreeNode)FindNode(tn.Nodes, "EmployeeID"); Assertion.AssertNotNull(treeNode); Assertion.Assert("Wrong type #1", treeNode is RelationNode); RelationNode rn = (RelationNode)treeNode; TableNode relTn = rn.RelatedTableNode; // tn is Orders, relTn is Employees treeNode = (NDOTreeNode)FindNode(relTn.Nodes, "EmployeeID", typeof(RelationNode)); Assertion.AssertNotNull(treeNode); RelationNode rn2 = (RelationNode)treeNode; Assertion.Assert(rn2.Relation is ForeignFkRelation); rn.DeleteFkRelation(null, EventArgs.Empty); treeNode = (NDOTreeNode)FindNode(tn.Nodes, "EmployeeID", typeof(RelationNode)); Assertion.AssertNull(treeNode); treeNode = (NDOTreeNode)FindNode(relTn.Nodes, "EmployeeID", typeof(RelationNode)); Assertion.AssertNull(treeNode); }
protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) { T4StatementBlock statementBlock = _highlighting.AssociatedNode; var file = statementBlock.GetContainingFile() as IT4File; Assertion.AssertNotNull(file, "file != null"); T4FeatureBlock feature = file.GetFeatureBlocks().First(); ITreeNode featureBlock; using (file.CreateWriteLock()) { // clone the statement block and add it before the feature block ITreeNode featurePrevSibling = feature.PrevSibling; featureBlock = ModificationUtil.CloneNode(statementBlock, node => { }); featureBlock = ModificationUtil.AddChildBefore(feature, featureBlock); // add a new line before the new statement block if needed if (featurePrevSibling != null && featurePrevSibling.GetTokenType() == T4TokenNodeTypes.NewLine) { ModificationUtil.AddChildAfter(featureBlock, T4TokenNodeTypes.NewLine.CreateLeafElement()); } ModificationUtil.DeleteChild(statementBlock); } return(textControl => { TextRange range = featureBlock.GetDocumentRange().TextRange; textControl.Caret.MoveTo(range.EndOffset, CaretVisualPlacement.Generic); }); }
void PrepareEmployeeTerritories(out TableNode tn) { ApplicationController.WizardControllerFactory = new WizardControllerFactory(this.GetType().Assembly, "TestApp.RelationTests+IntermediateTableWizController"); // Find Territories, map primary key, since it's not automatically detected, // and map class TreeNodeCollection nodes = ApplicationController.Instance.DatabaseNode.Nodes; tn = (TableNode)FindNode(nodes, "Territories"); ColumnNode cn = (ColumnNode)FindNode(tn.Nodes, "TerritoryID"); cn.ChangePrimary(null, EventArgs.Empty); tn.MapClass(null, EventArgs.Empty); tn.Table.ClassName = "Territory"; // Find Employees and map class tn = (TableNode)FindNode(nodes, "Employees"); tn.MapClass(null, EventArgs.Empty); tn.Table.ClassName = "Employee"; tn = (TableNode)FindNode(nodes, "EmployeeTerritories"); DatabaseNode dbn = (DatabaseNode)tn.Parent; Assertion.AssertNotNull("dbn shouldn't be null", dbn); tn.MapIntermediateTable(null, EventArgs.Empty); }
protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) { IInvocationExpression newExpression; using (WriteLockCookie.Create()) { var factory = CSharpElementFactory.GetInstance(myWarningCreationExpression); newExpression = (IInvocationExpression)factory.CreateExpression("gameObject.AddComponent<$0>()", myWarningCreationExpression.ExplicitType()); newExpression = ModificationUtil.ReplaceChild(myWarningCreationExpression, newExpression); } return(textControl => { var qualifier = newExpression.ExtensionQualifier; Assertion.AssertNotNull(qualifier, "qualifier != null"); var hotspotExpression = new MacroCallExpressionNew(new SuggestVariableOfTypeMacroDef()); hotspotExpression.AddParameter(new ConstantMacroParameter("UnityEngine.GameObject")); var field = new TemplateField("gameObject", hotspotExpression, 0); HotspotInfo[] fieldInfos = { new HotspotInfo(field, qualifier.GetDocumentRange()) }; var manager = LiveTemplatesManager.Instance; var invalidRange = DocumentRange.InvalidRange; var session = manager.CreateHotspotSessionAtopExistingText(solution, invalidRange, textControl, LiveTemplatesManager.EscapeAction.LeaveTextAndCaret, fieldInfos); session.Execute(); }); }
public static int GetInfoPrioirty(NetInfo info, NetInfo baseInfo = null) { PedestrianPathAI baseAI = baseInfo?.m_netAI as PedestrianPathAI; Assertion.AssertNotNull(baseAI, "baseAI"); if (info == baseAI.m_info) { return(0); } if (info == baseAI.m_elevatedInfo) { return(1); } if (info == baseAI.m_slopeInfo) { return(1); } if (info == baseAI.m_tunnelInfo) { return(2); } if (info == baseAI.m_bridgeInfo) { return(2); } Log.Error("Unreacahble code"); return(-1); }
private SerializerPair GetOrCreateMemberSerializer([NotNull] MemberInfo mi, [NotNull] Type serializerType, bool allowNullable) { if (!allowNullable) { ReflectionSerializerVerifier.AssertMemberDeclaration(mi); } else { ReflectionSerializerVerifier.AssertDataMemberDeclaration(mi); } if (!mySerializers.TryGetValue(serializerType, out var serializerPair)) { serializerPair = GetMemberSerializer(mi, serializerType.GetTypeInfo()); Assertion.AssertNotNull(serializerPair != null, $"Unable to Create serializer for type {serializerType.ToString(true)}"); mySerializers[serializerType] = serializerPair; } if (serializerPair == null) { #if JET_MODE_ASSERT Assertion.Fail($"Unable to create serializer for {serializerType.ToString(true)}: circular dependency detected: {string.Join(" -> ", myCurrentSerializersChain.Select(t => Types.ToString(t, true)).ToArray())}"); #endif throw new Assertion.AssertionException($"Undetected circular dependency during serializing {serializerType.ToString(true)}"); } return(serializerPair); }
public void TestDisambiguateProjectTargetName() { string solutionFileContents = @" Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project('{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}') = 'Build', 'Build\Build.csproj', '{21397922-C38F-4A0E-B950-77B3FBD51881}' EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {21397922-C38F-4A0E-B950-77B3FBD51881}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {21397922-C38F-4A0E-B950-77B3FBD51881}.Debug|Any CPU.Build.0 = Debug|Any CPU {21397922-C38F-4A0E-B950-77B3FBD51881}.Release|Any CPU.ActiveCfg = Release|Any CPU {21397922-C38F-4A0E-B950-77B3FBD51881}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal "; SolutionParser solution = SolutionParser_Tests.ParseSolutionHelper(solutionFileContents); Project msbuildProject = new Project(); SolutionWrapperProject.Generate(solution, msbuildProject, null, null); Assertion.AssertNotNull(msbuildProject.Targets["Build"]); Assertion.AssertNotNull(msbuildProject.Targets["Solution:Build"]); Assertion.AssertNotNull(msbuildProject.Targets["Solution:Build:Clean"]); Assertion.AssertNotNull(msbuildProject.Targets["Solution:Build:Rebuild"]); Assertion.AssertNotNull(msbuildProject.Targets["Solution:Build:Publish"]); Assertion.AssertEquals(null, msbuildProject.Targets["Build"].TargetElement.ChildNodes[0].Attributes["Targets"]); Assertion.AssertEquals("Clean", msbuildProject.Targets["Clean"].TargetElement.ChildNodes[0].Attributes["Targets"].Value); Assertion.AssertEquals("Rebuild", msbuildProject.Targets["Rebuild"].TargetElement.ChildNodes[0].Attributes["Targets"].Value); Assertion.AssertEquals("Publish", msbuildProject.Targets["Publish"].TargetElement.ChildNodes[0].Attributes["Targets"].Value); Assertion.AssertEquals("@(BuildLevel0)", msbuildProject.Targets["Build"].TargetElement.ChildNodes[0].Attributes["Projects"].Value); Assertion.AssertEquals("@(BuildLevel0)", msbuildProject.Targets["Clean"].TargetElement.ChildNodes[0].Attributes["Projects"].Value); Assertion.AssertEquals("@(BuildLevel0)", msbuildProject.Targets["Rebuild"].TargetElement.ChildNodes[0].Attributes["Projects"].Value); Assertion.AssertEquals("@(BuildLevel0)", msbuildProject.Targets["Publish"].TargetElement.ChildNodes[0].Attributes["Projects"].Value); // Here we check that the set of standard entry point targets in the solution project // matches those defined in ProjectInSolution.projectNamesToDisambiguate = { "Build", "Rebuild", "Clean", "Publish" }; int countOfStandardTargets = 0; foreach (Target t in msbuildProject.Targets) { if (!t.Name.Contains(":")) { countOfStandardTargets += 1; } } // NOTE: ValidateSolutionConfiguration and ValidateToolsVersions are always added, so we need to add two extras Assertion.AssertEquals(ProjectInSolution.projectNamesToDisambiguate.Length + 2, countOfStandardTargets); }
public void testStudentMealMappings() { StudentMeal sm = new StudentMeal(); Mappings mappings = fCfg.Mappings.GetMappings("Default"); IDictionary map = new Hashtable(); map.Add("Balance", "10.55"); StringMapAdaptor sma = new StringMapAdaptor(map); mappings.MapOutbound(sma, sm); sm = (StudentMeal)AdkObjectParseHelper.WriteParseAndReturn(sm, fVersion); // Assert that the object was mapped correctly FSAmounts amounts = sm.Amounts; Assertion.AssertNotNull(amounts); FSAmount amount = amounts.ItemAt(0); Assertion.Assert(amount.Value.HasValue); Assertion.AssertEquals(10.55, amount.Value.Value); // Now, map the object back to a hashmap and assert it IDictionary restoredData = new Hashtable(); sma = new StringMapAdaptor(restoredData); mappings.MapInbound(sm, sma); assertMapsAreEqual(map, restoredData); }
private void AssertProjectItemNameCount(Project msbuildProject, string itemName, int count) { BuildItemGroup itemGroup = (BuildItemGroup)msbuildProject.EvaluatedItemsByName[itemName]; Assertion.AssertNotNull(itemGroup); Assertion.AssertEquals(count, itemGroup.Count); }
public void TestAddRoleToSPSiteSimple() { String addPerms = ""; string result = result = RunBuild(String.Format(CultureInfo.InvariantCulture, _xmlProjectTemplate, _newSPSiteUrl, "true", _testRoleName, _roleDescription, "", addPerms)); SPSite site = new SPSite(_newSPSiteUrl); SPRole newRole = site.RootWeb.Roles[_testRoleName]; Assertion.AssertNotNull("New Role is null!", newRole); // Construct the rights the role should have for comparison. The // base permission of a role defaults to the permission of the // "Guest" role. From there we add anything other permissions // the role should have. SPRights rights = site.RootWeb.Roles["Guest"].PermissionMask; Assertion.AssertEquals("permissions were not correctly modified.", 0, rights.CompareTo(newRole.PermissionMask)); }
// make serailizer SimpleDataSerializer(Version version, int capacity) { Stream = new MemoryStream(capacity); Assertion.AssertNotNull(version); Version = version; WriteVersion(version); }
protected override bool AddLookupItems(T4CodeCompletionContext context, IItemsCollector collector) { ITreeNode node = context.BasicContext.File.FindNodeAt(context.BasicContext.SelectedTreeRange); Assertion.AssertNotNull(node, "node == null"); var ranges = context.BasicContext.GetRanges(node); collector.AddRanges(ranges); var attribute = node.GetContainingNode <IT4DirectiveAttribute>(); Assertion.AssertNotNull(attribute, "attribute != null"); var directive = attribute.GetContainingNode <IT4Directive>(); Assertion.AssertNotNull(directive, "directive != null"); DirectiveInfo directiveInfo = _directiveInfoManager.GetDirectiveByName(directive.GetName()); DirectiveAttributeInfo attributeInfo = directiveInfo?.GetAttributeByName(attribute.GetName()); if (attributeInfo == null) { return(false); } foreach (string intellisenseValue in attributeInfo.IntelliSenseValues) { var item = new TextLookupItem(intellisenseValue); item.InitializeRanges(ranges, context.BasicContext); collector.Add(item); } return(true); }
public void testParseProjectedGradYear() { String sXML = "<StudentPersonal RefId='12345678901234567890'>" + " <GradYear Type='Projected'>2012</GradYear>" + "</StudentPersonal>"; StudentPersonal sp = (StudentPersonal)parseSIF15r1XML(sXML); sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11); Assertion.AssertNotNull(sp); Assertion.AssertNotNull("Projected Grad Year", sp.ProjectedGraduationYear); Assertion.AssertEquals("Projected Grad Year", 2012, (int)sp .ProjectedGraduationYear); Adk.SifVersion = SifVersion.SIF15r1; sp = new StudentPersonal(); sp.SetElementOrAttribute("GradYear[@Type='Projected']", "2089"); Assertion.AssertNotNull("Projected Grad Year", sp.ProjectedGraduationYear); Assertion.AssertEquals("Projected Grad Year", 2089, (int)sp .ProjectedGraduationYear); Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Projected']"); Assertion.AssertNotNull("Projected Grad Year", gradValue); int gradYear = (int)gradValue.SifValue.RawValue; Assertion.AssertNotNull("Projected Grad Year", gradYear); Assertion.AssertEquals("Projected Grad Year", 2089, gradYear); }