protected override void ExecuteSetup(CreateFabMember pCre) { pCre.DefinedByAppId = 4362346234; pCre.DefinedByUserId = 6326234; pCre.Type = (byte)MemberType.Id.Staff; ICreateOperationBuilder build = MockBuild.Object; IWeaverVarAlias <Member> alias = new WeaverVarAlias <Member>("test"); MockTasks .Setup(x => x.FindDuplicateMember(build, pCre.DefinedByUserId, pCre.DefinedByAppId)) .Callback(CheckCallIndex("FindDuplicateMemberNameKey")); MockTasks .Setup(x => x.AddMember(build, ItIsVert <Member>(VertId), out alias)) .Callback(CheckCallIndex("AddMember")); MockTasks .Setup(x => x.AddMemberDefinedByApp( build, ItIsVert <Member>(VertId), It.Is <CreateFabMember>(c => c.DefinedByAppId == pCre.DefinedByAppId), alias )) .Callback(CheckCallIndex("AddMemberDefinedByApp")); MockTasks .Setup(x => x.AddMemberDefinedByUser( build, ItIsVert <Member>(VertId), It.Is <CreateFabMember>(c => c.DefinedByUserId == pCre.DefinedByUserId), alias )) .Callback(CheckCallIndex("AddMemberDefinedByUser")); }
public void NewT() { const string name = "xyz_T"; var mockTx = new Mock <IWeaverTransaction>(); mockTx.Setup(x => x.GetNextVarName()).Returns(name); WeaverVarAlias va = new WeaverVarAlias <Person>(name); Assert.AreEqual(name, va.Name, "Incorrect Name."); Assert.AreEqual(typeof(Person), va.VarType, "Incorrect VarType."); }
public void GetNameOfGrandchildOfSaturn() { //saturn.in('father').in('father').name var v = new WeaverVarAlias <Character>("saturn"); IWeaverQuery q = Traversals.GetGrandchildOfCharacter(v) .Property(x => x.Name) .ToQuery(); string expectScript = "saturn.inE('father').outV.inE('father').outV.property('name');"; Assert.AreEqual(expectScript, q.Script, "Incorrect script."); }
public void Finish(bool pWithVar) { var txb = new TxBuilder(); Assert.Null(txb.Transaction.Script, "Script should be empty before Finish()."); if (pWithVar) { var v = new WeaverVarAlias("test"); txb.RegisterVarWithTxBuilder(v); txb.Finish(v); } else { txb.Finish(); } Assert.NotNull("", txb.Transaction.Script, "Script should be filled after Finish()."); }
public void AddEdgeUnregisteredVar(bool pFirst) { var edge = new ArtifactCreatedByMember(); var artAlias = new WeaverVarAlias <Artifact>("art"); var memAlias = new WeaverVarAlias <Member>("mem"); var txb = new TxBuilder(); if (pFirst) { txb.RegisterVarWithTxBuilder(artAlias); } else { txb.RegisterVarWithTxBuilder(memAlias); } TestUtil.Throws <Exception>(() => txb.AddEdge(artAlias, edge, memAlias)); }
public void New(bool pWithType) { const string name = "xyz"; Type varType = typeof(object); WeaverVarAlias va; if (pWithType) { va = new WeaverVarAlias(name); } else { varType = typeof(Person); va = new WeaverVarAlias(name, varType); } Assert.AreEqual(name, va.Name, "Incorrect Name."); Assert.AreEqual(varType, va.VarType, "Incorrect VarType."); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override void ExecuteSetup(CreateFabInstance pCre) { pCre.Name = "Test Name"; pCre.Disamb = "Test Disamb"; pCre.Note = "Test Note"; ICreateOperationBuilder build = MockBuild.Object; IWeaverVarAlias <Instance> alias = new WeaverVarAlias <Instance>("test"); MockTasks .Setup(x => x.AddInstance(build, ItIsVert <Instance>(VertId), out alias)) .Callback(CheckCallIndex("AddInstance")); MockTasks .Setup(x => x.AddArtifactCreatedByMember( build, ItIsVert <Instance>(VertId), It.Is <CreateFabInstance>(c => c.CreatedByMemberId == MemId), It.Is <IWeaverVarAlias <Artifact> >(a => a.Name == alias.Name) )) .Callback(CheckCallIndex("AddArtifactCreatedByMember")); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override void ExecuteSetup(CreateFabEmail pCre) { pCre.Address = "*****@*****.**"; pCre.Code = "12345678901234567890123456789012"; pCre.Verified = false; pCre.UsedByArtifactId = 1641346431; ICreateOperationBuilder build = MockBuild.Object; IWeaverVarAlias <Email> alias = new WeaverVarAlias <Email>("test"); MockTasks .Setup(x => x.AddEmail(build, ItIsVert <Email>(VertId), out alias)) .Callback(CheckCallIndex("AddEmail")); MockTasks .Setup(x => x.AddEmailUsedByArtifact( build, ItIsVert <Email>(VertId), It.Is <CreateFabEmail>(c => c.UsedByArtifactId == pCre.UsedByArtifactId), It.Is <IWeaverVarAlias <Email> >(a => a.Name == alias.Name) )) .Callback(CheckCallIndex("AddEmailUsedByArtifact")); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override void ExecuteSetup(CreateFabOauthAccess pCre) { pCre.Token = "12345678901234567890123456789012"; pCre.Refresh = "ABcd5678901234567890123456789012"; pCre.Expires = 13461234623; pCre.AuthenticatesMemberId = 1641346431; ICreateOperationBuilder build = MockBuild.Object; IWeaverVarAlias <OauthAccess> alias = new WeaverVarAlias <OauthAccess>("test"); MockTasks .Setup(x => x.AddOauthAccess(build, ItIsVert <OauthAccess>(VertId), out alias)) .Callback(CheckCallIndex("AddOauthAccess")); MockTasks .Setup(x => x.AddOauthAccessAuthenticatesMember( build, ItIsVert <OauthAccess>(VertId), It.Is <CreateFabOauthAccess>( c => c.AuthenticatesMemberId == pCre.AuthenticatesMemberId), It.Is <IWeaverVarAlias <OauthAccess> >(a => a.Name == alias.Name) )) .Callback(CheckCallIndex("AddOauthAccessAuthenticatesMember")); }
public void AddEdge() { var edge = new ArtifactCreatedByMember(); var artAlias = new WeaverVarAlias <Artifact>("art"); var memAlias = new WeaverVarAlias <Member>("mem"); const string expectScript = "g.addEdge(art,mem,_P0);"; var txb = new TxBuilder(); txb.RegisterVarWithTxBuilder(artAlias); txb.RegisterVarWithTxBuilder(memAlias); txb.AddEdge(artAlias, edge, memAlias); IWeaverQuery q = GetFirstQuery(txb); TestUtil.LogWeaverScript(Log, q); Assert.AreEqual(expectScript, q.Script, "Incorrect script."); TestUtil.CheckParams(q.Params, "_P", new List <object> { DbName.Edge.ArtifactCreatedByMemberName }); }
public void Execute() { const string name = "Test App"; const long creatorMemId = 123523532; const long userId = 12316232336666; ICreateOperationBuilder build = MockBuild.Object; CreateOperationTasks tasks = MockTasks.Object; var expectApp = new App(); var expectMem = new Member(); IWeaverVarAlias <App> appAlias = new WeaverVarAlias <App>("appAlias"); IWeaverVarAlias <Member> memAlias = new WeaverVarAlias <Member>("memAlias"); MockBuild .Setup(x => x.StartSession()) .Callback(CheckCallIndex("StartSession")); //// Add App MockTasks .Setup(x => x.FindDuplicateAppNameKey(build, ItIsVert <App>(vNewAppId))) .Callback(CheckCallIndex("FindDuplicateAppNameKey")); int addAppIndex = CallsAdded; MockTasks .Setup(x => x.AddApp(build, ItIsVert <App>(vNewAppId), out appAlias)) .Callback(CheckCallIndex("AddApp")); //// Add Member MockTasks .Setup(x => x.FindDuplicateMember(build, userId, vNewAppId)) .Callback(CheckCallIndex("FindDuplicateMember")); int addMemIndex = CallsAdded; MockTasks .Setup(x => x.AddMember(build, ItIsVert <Member>(vNewMemId), out memAlias)) .Callback(CheckCallIndex("AddMember")); //// Add App edges MockTasks .Setup(x => x.AddArtifactCreatedByMember( build, ItIsVert <App>(vNewAppId), It.Is <CreateFabApp>(c => c.CreatedByMemberId == creatorMemId), It.Is <IWeaverVarAlias <Artifact> >(a => a.Name == appAlias.Name) )) .Callback(CheckCallIndex("AddArtifactCreatedByMember")); //// Add Member edges MockTasks .Setup(x => x.AddMemberDefinedByApp( build, ItIsVert <Member>(vNewMemId), It.Is <CreateFabMember>(c => c.DefinedByAppId == vNewAppId), It.Is <IWeaverVarAlias <Member> >(a => a.Name == memAlias.Name) )) .Callback(CheckCallIndex("AddMemberDefinedByApp")); MockTasks .Setup(x => x.AddMemberDefinedByUser( build, ItIsVert <Member>(vNewMemId), It.Is <CreateFabMember>(c => c.DefinedByUserId == userId), It.Is <IWeaverVarAlias <Member> >(a => a.Name == memAlias.Name) )) .Callback(CheckCallIndex("AddMemberDefinedByUser")); //// Finish setup MockBuild .Setup(x => x.CommitAndCloseSession()) .Callback(CheckCallIndex("CommitAndCloseSession")); MockAcc.Setup(x => x.Execute(typeof(CreateAppAccountOperation).Name)) .Returns(MockRes.Object); MockRes.Setup(x => x.GetCommandIndexByCmdId(vAppCmd)).Returns(addAppIndex); MockRes.Setup(x => x.GetCommandIndexByCmdId(vMemCmd)).Returns(addMemIndex); MockRes.Setup(x => x.ToElementAt <App>(addAppIndex, 0)).Returns(expectApp); MockRes.Setup(x => x.ToElementAt <Member>(addMemIndex, 0)).Returns(expectMem); //// Execute var op = new CreateAppAccountOperation(); CreateAppAccountOperation.Result result = op.Execute(MockOpCtx.Object, build, tasks, name, creatorMemId, userId); Assert.NotNull(result, "Result should be filled."); Assert.AreEqual(CreateAppAccountOperation.ResultStatus.Success, result.Status, "Incorrect Status"); Assert.AreEqual(expectApp, result.NewApp, "Incorrect NewApp."); Assert.AreEqual(expectMem, result.NewMember, "Incorrect NewMember."); }
public void Execute() { const string email = "*****@*****.**"; const string username = "******"; const string password = "******"; const long fabAppId = (long)SetupAppId.FabSys; ICreateOperationBuilder build = MockBuild.Object; CreateOperationTasks tasks = MockTasks.Object; var expectUser = new User(); var expectMem = new Member(); var expectEmail = new Email(); IWeaverVarAlias <User> userAlias = new WeaverVarAlias <User>("userAlias"); IWeaverVarAlias <Member> memAlias = new WeaverVarAlias <Member>("memAlias"); IWeaverVarAlias <Email> emailAlias = new WeaverVarAlias <Email>("emailAlias"); MockData.Setup(x => x.Get <Email>(It.IsAny <IWeaverQuery>(), typeof(CreateUserAccountOperation).Name + "-FindDuplicateEmail")) .Returns((Email)null); MockBuild .Setup(x => x.StartSession()) .Callback(CheckCallIndex("StartSession")); //// Add App MockTasks .Setup(x => x.FindDuplicateUserNameKey(build, ItIsVert <User>(vNewUserId))) .Callback(CheckCallIndex("FindDuplicateUserNameKey")); int addAppIndex = CallsAdded; MockTasks .Setup(x => x.AddUser(build, ItIsVert <User>(vNewUserId), out userAlias)) .Callback(CheckCallIndex("AddUser")); //// Add Member MockTasks .Setup(x => x.FindDuplicateMember(build, vNewUserId, fabAppId)) .Callback(CheckCallIndex("FindDuplicateMember")); int addMemIndex = CallsAdded; MockTasks .Setup(x => x.AddMember(build, ItIsVert <Member>(vNewMemId), out memAlias)) .Callback(CheckCallIndex("AddMember")); //// Add Email int addEmailIndex = CallsAdded; MockTasks .Setup(x => x.AddEmail(build, ItIsVert <Email>(vNewEmailId), out emailAlias)) .Callback(CheckCallIndex("AddEmail")); //// Add App edges MockTasks .Setup(x => x.AddArtifactCreatedByMember( build, ItIsVert <User>(vNewUserId), It.Is <CreateFabUser>(c => c.CreatedByMemberId == vNewMemId), It.Is <IWeaverVarAlias <Artifact> >(a => a.Name == userAlias.Name) )) .Callback(CheckCallIndex("AddArtifactCreatedByMember")); //// Add Member edges MockTasks .Setup(x => x.AddMemberDefinedByApp( build, ItIsVert <Member>(vNewMemId), It.Is <CreateFabMember>(c => c.DefinedByAppId == fabAppId), It.Is <IWeaverVarAlias <Member> >(a => a.Name == memAlias.Name) )) .Callback(CheckCallIndex("AddMemberDefinedByApp")); MockTasks .Setup(x => x.AddMemberDefinedByUser( build, ItIsVert <Member>(vNewMemId), It.Is <CreateFabMember>(c => c.DefinedByUserId == vNewUserId), It.Is <IWeaverVarAlias <Member> >(a => a.Name == memAlias.Name) )) .Callback(CheckCallIndex("AddMemberDefinedByUser")); //// Add Email edges MockTasks .Setup(x => x.AddEmailUsedByArtifact( build, ItIsVert <Email>(vNewEmailId), It.Is <CreateFabEmail>(c => c.UsedByArtifactId == vNewUserId), It.Is <IWeaverVarAlias <Email> >(a => a.Name == emailAlias.Name) )) .Callback(CheckCallIndex("AddEmailUsedByArtifact")); //// Finish setup MockBuild .Setup(x => x.CommitAndCloseSession()) .Callback(CheckCallIndex("CommitAndCloseSession")); MockAcc.Setup(x => x.Execute(typeof(CreateUserAccountOperation).Name)) .Returns(MockRes.Object); MockRes.Setup(x => x.GetCommandIndexByCmdId(vUserCmd)).Returns(addAppIndex); MockRes.Setup(x => x.GetCommandIndexByCmdId(vMemCmd)).Returns(addMemIndex); MockRes.Setup(x => x.GetCommandIndexByCmdId(vEmailCmd)).Returns(addEmailIndex); MockRes.Setup(x => x.ToElementAt <User>(addAppIndex, 0)).Returns(expectUser); MockRes.Setup(x => x.ToElementAt <Member>(addMemIndex, 0)).Returns(expectMem); MockRes.Setup(x => x.ToElementAt <Email>(addEmailIndex, 0)).Returns(expectEmail); //// Execute var op = new CreateUserAccountOperation(); CreateUserAccountOperation.Result result = op.Execute(MockOpCtx.Object, build, tasks, email, username, password); Assert.NotNull(result, "Result should be filled."); Assert.AreEqual(CreateUserAccountOperation.ResultStatus.Success, result.Status, "Incorrect Status"); Assert.AreEqual(expectUser, result.NewUser, "Incorrect NewApp."); Assert.AreEqual(expectMem, result.NewMember, "Incorrect NewMember."); Assert.AreEqual(expectEmail, result.NewEmail, "Incorrect NewEmail."); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override void ExecuteSetup(CreateFabFactor pCre) { pCre.AssertionType = (byte)FactorAssertion.Id.Opinion; pCre.IsDefining = true; pCre.Note = "My Note"; pCre.UsesPrimaryArtifactId = 12961924; pCre.UsesRelatedArtifactId = 36373527463; pCre.Descriptor = new CreateFabDescriptor(); pCre.Descriptor.Type = (byte)DescriptorType.Id.IsAnInstanceOf; pCre.Descriptor.RefinesPrimaryWithArtifactId = 9876544; pCre.Descriptor.RefinesRelatedWithArtifactId = 453453; pCre.Descriptor.RefinesTypeWithArtifactId = 3735727; pCre.Director = new CreateFabDirector(); pCre.Director.Type = 9; pCre.Director.PrimaryAction = 8; pCre.Director.RelatedAction = 7; pCre.Eventor = new CreateFabEventor(); pCre.Eventor.Type = 6; pCre.Eventor.Year = 2000; pCre.Eventor.Month = 11; pCre.Eventor.Day = 29; pCre.Eventor.Hour = 11; pCre.Eventor.Minute = 51; pCre.Eventor.Second = 52; pCre.Identor = new CreateFabIdentor(); pCre.Identor.Type = 13; pCre.Identor.Value = "MyIdentorVal"; pCre.Locator = new CreateFabLocator(); pCre.Locator.Type = 22; pCre.Locator.ValueX = 1.234; pCre.Locator.ValueY = 12.3456; pCre.Locator.ValueZ = 123.4567; pCre.Vector = new CreateFabVector(); pCre.Vector.Type = 2; pCre.Vector.Unit = 3; pCre.Vector.UnitPrefix = 4; pCre.Vector.Value = 21464; pCre.Vector.UsesAxisArtifactId = 3235723; ICreateOperationBuilder build = MockBuild.Object; IWeaverVarAlias <Factor> alias = new WeaverVarAlias <Factor>("test"); MockTasks .Setup(x => x.AddFactor(build, ItIsVert <Factor>(VertId), out alias)) .Callback(CheckCallIndex("AddFactor")); MockTasks.Verify(); MockTasks .Setup(x => x.AddFactorCreatedByMember( build, ItIsVert <Factor>(VertId), It.Is <CreateFabFactor>(c => c.CreatedByMemberId == MemId), alias )) .Callback(CheckCallIndex("AddArtifactCreatedByMember")); MockTasks .Setup(x => x.AddFactorDescriptorRefinesPrimaryWithArtifact( build, ItIsVert <Factor>(VertId), It.Is <CreateFabFactor>(c => c.Descriptor.RefinesPrimaryWithArtifactId == pCre.Descriptor.RefinesPrimaryWithArtifactId), alias )) .Callback(CheckCallIndex("AddFactorDescriptorRefinesPrimaryWithArtifact")); MockTasks .Setup(x => x.AddFactorDescriptorRefinesRelatedWithArtifact( build, ItIsVert <Factor>(VertId), It.Is <CreateFabFactor>(c => c.Descriptor.RefinesRelatedWithArtifactId == pCre.Descriptor.RefinesRelatedWithArtifactId), alias )) .Callback(CheckCallIndex("AddFactorDescriptorRefinesRelatedWithArtifact")); MockTasks .Setup(x => x.AddFactorDescriptorRefinesTypeWithArtifact( build, ItIsVert <Factor>(VertId), It.Is <CreateFabFactor>(c => c.Descriptor.RefinesTypeWithArtifactId == pCre.Descriptor.RefinesTypeWithArtifactId), alias )) .Callback(CheckCallIndex("AddFactorDescriptorRefinesTypeWithArtifact")); MockTasks .Setup(x => x.AddFactorUsesPrimaryArtifact( build, ItIsVert <Factor>(VertId), It.Is <CreateFabFactor>(c => c.UsesPrimaryArtifactId == pCre.UsesPrimaryArtifactId), alias )) .Callback(CheckCallIndex("AddFactorUsesPrimaryArtifact")); MockTasks .Setup(x => x.AddFactorUsesRelatedArtifact( build, ItIsVert <Factor>(VertId), It.Is <CreateFabFactor>(c => c.UsesRelatedArtifactId == pCre.UsesRelatedArtifactId), alias )) .Callback(CheckCallIndex("AddFactorUsesRelatedArtifact")); MockTasks .Setup(x => x.AddFactorVectorUsesAxisArtifact( build, ItIsVert <Factor>(VertId), It.Is <CreateFabFactor>(c => c.Vector.UsesAxisArtifactId == pCre.Vector.UsesAxisArtifactId), alias )) .Callback(CheckCallIndex("AddFactorVectorUsesAxisArtifact")); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public WeaverStepTable(IWeaverElement pElem, out IWeaverVarAlias pAlias) { Alias = pAlias = new WeaverVarAlias("_TABLE" + pElem.Path.Length); }