private dynamic SpawnIdentity(Type type, EndPointId clientId, NetworkIdentity identity = null) { lock (NetworkIdentity.entities) { NetworkIdentity.lastId++; IdentityId id = NetworkIdentity.lastId; string[] args = null; if (identity != null) { Dictionary <string, string> valuesByFields = GetValuesByFieldsFromObject(identity); args = valuesByFields.Select(k => k.Key + "+" + k.Value).ToArray(); } NetworkIdentity newIdentity = Activator.CreateInstance(type) as NetworkIdentity; EndPointId owner = EndPointId.InvalidIdentityId; if (clientId == EndPointId.InvalidIdentityId) { owner = serverEndPointId; } else { owner = clientId; } SpawnObjectPacket packet = new SpawnObjectPacket(true, newIdentity.GetType(), id, owner, false, args); BroadcastPacket(packet, NetworkInterfaceType.TCP); InitIdentityLocally(newIdentity, owner, id, false, args); return(newIdentity); } }
public void TestClaimsIdentityGetGroups() { IdentityId id = new IdentityId(); Mock<IAccountFactory> mock = new Mock<IAccountFactory>(MockBehavior.Strict); mock.Setup(m => m.GetAccount(It.IsAny<IdentityId>())). Returns(() => new Account(id, "nativeId-group", "test", AccountType.Group)).Verifiable(); mock.Setup(m => m.GetGroups(It.IsAny<IdentityId>())).Verifiable(); mock.Setup(m => m.GetRoles(It.IsAny<IdentityId>())).Verifiable(); _container.Register(Component.For(typeof(IAccountFactory)).UsingFactoryMethod(() => mock.Object)); IClaimsIdentity claimsIdentity = new ClaimsIdentity(id) ; claimsIdentity.Claims.Add(new Claim(ClaimType.Group.ToString(), new IdentityId().ToString())); claimsIdentity.Claims.Add(new Claim(ClaimType.Group.ToString(), new IdentityId().ToString())); claimsIdentity.Claims.Add(new Claim(ClaimType.Group.ToString(), new IdentityId().ToString())); claimsIdentity.Claims.Add(new Claim(ClaimType.Group.ToString(), new IdentityId().ToString())); IEnumerable<IIdentity> groups = claimsIdentity.MemberOf(); Assert.IsNotNull(groups); Assert.AreEqual(4, groups.Count()); foreach (IIdentity identity in groups) { Assert.IsTrue(identity is IdentitySurrogate); } mock.Verify(m => m.GetRoles(It.IsAny<IdentityId>()), Times.Never()); mock.Verify(m => m.GetAccount(It.IsAny<IdentityId>()), Times.Never()); mock.Verify(m => m.GetGroups(It.IsAny<IdentityId>()), Times.Never()); }
public Customer(IdentityId identityId, Name name) { Id = Guid.NewGuid(); Name = name; IdentityId = identityId; _accounts = new AccountCollection(); }
/// <summary> /// Returns true if ExecuteParameters instances are equal /// </summary> /// <param name="other">Instance of ExecuteParameters to be compared</param> /// <returns>Boolean</returns> public bool Equals(ExecuteParameters other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( IdentityId == other.IdentityId || IdentityId != null && IdentityId.Equals(other.IdentityId) ) && ( Parameter == other.Parameter || Parameter != null && Parameter.Equals(other.Parameter) ) && ( ProcessInstance == other.ProcessInstance || ProcessInstance != null && ProcessInstance.Equals(other.ProcessInstance) )); }
internal SyncObjectVars(bool shouldInvokeSynchronously, IdentityId id, params string[] spawnParams) : base(PacketId.SyncObjectVars, shouldInvokeSynchronously, id) { SpawnParamCount = spawnParams.Count(); SpawnParams = spawnParams; Data.Add(SpawnParamCount); Data.AddRange(SpawnParams); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (IdentityId != null) { hashCode = hashCode * 59 + IdentityId.GetHashCode(); } if (Parameter != null) { hashCode = hashCode * 59 + Parameter.GetHashCode(); } if (ProcessInstance != null) { hashCode = hashCode * 59 + ProcessInstance.GetHashCode(); } return(hashCode); } }
internal SyncVarPacket(IdentityId networkIdentityId, string locationName, object locationValue, bool shouldInvokeSynchronously) : base(PacketId.SyncVar, shouldInvokeSynchronously, networkIdentityId) { LocationName = locationName; LocationValue = locationValue; Data.Add(LocationName); Data.Add(LocationValue); }
public Customer Register(IdentityId identityId, Name name) { var customer = new Customer(identityId, name); _customerRepository.Add(customer); return(customer); }
/// <summary> /// Returns true if HistoryItem instances are equal /// </summary> /// <param name="other">Instance of HistoryItem to be compared</param> /// <returns>Boolean</returns> public bool Equals(HistoryItem other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( ProcessId == other.ProcessId || ProcessId != null && ProcessId.Equals(other.ProcessId) ) && ( IdentityId == other.IdentityId || IdentityId != null && IdentityId.Equals(other.IdentityId) ) && ( AllowedToEmployeeNames == other.AllowedToEmployeeNames || AllowedToEmployeeNames != null && AllowedToEmployeeNames.Equals(other.AllowedToEmployeeNames) ) && ( TransitionTime == other.TransitionTime || TransitionTime != null && TransitionTime.Equals(other.TransitionTime) ) && ( Order == other.Order || Order != null && Order.Equals(other.Order) ) && ( InitialState == other.InitialState || InitialState != null && InitialState.Equals(other.InitialState) ) && ( DestinationState == other.DestinationState || DestinationState != null && DestinationState.Equals(other.DestinationState) ) && ( Command == other.Command || Command != null && Command.Equals(other.Command) )); }
internal static NetworkIdentity GetNetworkIdentityById(IdentityId identityId) { lock (entities) { if (!NetworkIdentity.entities.TryGetValue(identityId, out NetworkIdentity identity)) { return(null); } return(identity); } }
public static Customer Load(Guid id, Name name, IdentityId identityId, AccountCollection accounts) { Customer customer = new Customer(); customer.Id = id; customer.Name = name; customer.IdentityId = identityId; customer._accounts = accounts; return(customer); }
public void Valid_Identity_Id_Should_Be_Created() { //arrange string valid = "12345678901"; //act IdentityId identityId = new IdentityId(valid); //Assert Assert.Equal(valid, identityId); }
public MethodPacket(PacketId packetId, IdentityId id, string methodName, bool shouldInvokeSynchronously, object[] methodArgs) : base(packetId, shouldInvokeSynchronously, id) { MethodName = methodName; MethodArgsCount = methodArgs.Count(); MethodArgs = methodArgs; Data.Add(MethodName); Data.Add(MethodArgsCount); if (MethodArgs != null) { Data.AddRange(MethodArgs); } }
public void TestCreateToReadyMultiplePotentialOwners() { IdentityId initiatorId = new IdentityId(); IdentityId potentialOwnerOne = new IdentityId(); IdentityId potentialOwnerTwo = new IdentityId(); IdentityId businessAdminId = new IdentityId(); IPrincipal initiator = new ClaimsPrincipal(initiatorId.GetIdentity()); _mapStorage[potentialOwnerOne.Id] = new Account(potentialOwnerOne, "s-1-2-3-4-5", "auth", AccountType.User); _mapStorage[potentialOwnerTwo.Id] = new Account(potentialOwnerTwo, "s-1-2-3-4-5", "auth", AccountType.User); _mapStorage[businessAdminId.Id] = new Account(businessAdminId, "s-55-2-3-4-5", "auth", AccountType.User); ILoggingService loggingService = SetupLoggerMock(new List<TaskHistoryEvent> { new TaskHistoryEvent{ Event = "Create", OldStatus = TaskStatus.None, NewStatus = TaskStatus.Created, OldPriority = Priority.Normal, NewPriority = Priority.Normal, Comment = "", TimeStamp = DateTime.UtcNow, UserId = initiator.Identity.GetMappedId()} }); Thread.CurrentPrincipal = initiator; Task task = new Task(new TaskId(), TaskStatus.Created, string.Empty, string.Empty, Priority.Normal, false, DateTime.UtcNow, initiator.Identity, null, null, null) { LoggingService = loggingService }; Assert.AreEqual(TaskStatus.Created, task.Status); task.PotentialOwners.Add(potentialOwnerOne.GetIdentity()); task.PotentialOwners.Add(potentialOwnerTwo.GetIdentity()); task.BusinessAdministrators.Add(businessAdminId.GetIdentity()); Assert.IsNotNull(task); Assert.AreEqual(TaskStatus.Created, task.Status); IPrincipal businessAdmin = new ClaimsPrincipal(businessAdminId.GetIdentity()); Thread.CurrentPrincipal = businessAdmin; task.Activate(); Assert.AreEqual(TaskStatus.Ready, task.Status); Assert.IsNull(task.ActualOwner); Assert.IsNotNull(task.History); Assert.AreEqual(2, task.History.Count()); TaskHistoryEvent history = task.History.ElementAt(0); Assert.IsNotNull(history); Assert.AreEqual(TaskStatus.None, history.OldStatus); Assert.AreEqual(TaskStatus.Created, history.NewStatus); Assert.AreEqual(initiator.Identity.GetMappedId(), history.UserId); history = task.History.ElementAt(1); Assert.IsNotNull(history); }
/// <summary> /// Initializes a new instance of the <see cref="IdentitySurrogate"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="externalId">The external id.</param> /// <param name="name">The name.</param> /// <param name="authenticationType">Type of the authentication.</param> /// <param name="isGroup">if set to <c>true</c> [is group].</param> /// <param name="isRole">if set to <c>true</c> [is role].</param> public IdentitySurrogate(IdentityId id, string externalId, string name, string authenticationType, bool isGroup, bool isRole ) { Id = id; ExternalId = externalId; Name = name; AuthenticationType = authenticationType; IsRole = isRole; IsGroup = isGroup; }
internal SpawnPacket(PacketId packetID, bool shouldInvokeSynchronously, IdentityId id, Type instance, EndPointId ownerId, bool spawnDuringSync, params object[] spawnParams) : base(packetID, shouldInvokeSynchronously, id) { InstanceName = instance.FullName; OwnerId = ownerId; SpawnDuringSync = spawnDuringSync; SpawnParamCount = spawnParams != null?spawnParams.Count() : 0; SpawnParams = spawnParams; Data.Add(InstanceName); Data.Add(OwnerId.Id); Data.Add(SpawnDuringSync); Data.Add(SpawnParamCount); if (SpawnParams != null) { Data.AddRange(SpawnParams); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (ProcessId != null) { hashCode = hashCode * 59 + ProcessId.GetHashCode(); } if (IdentityId != null) { hashCode = hashCode * 59 + IdentityId.GetHashCode(); } if (AllowedToEmployeeNames != null) { hashCode = hashCode * 59 + AllowedToEmployeeNames.GetHashCode(); } if (TransitionTime != null) { hashCode = hashCode * 59 + TransitionTime.GetHashCode(); } if (Order != null) { hashCode = hashCode * 59 + Order.GetHashCode(); } if (InitialState != null) { hashCode = hashCode * 59 + InitialState.GetHashCode(); } if (DestinationState != null) { hashCode = hashCode * 59 + DestinationState.GetHashCode(); } if (Command != null) { hashCode = hashCode * 59 + Command.GetHashCode(); } return(hashCode); } }
protected override void WriteDataOnParent(MainForm frm, Control parent, ref Point location) { EventLabel(frm, parent, ref location, "Trickster:", Hf_Trickster); if (Hf_Identity != null) { EventLabel(frm, parent, ref location, "Identity:", Hf_Identity); } else if (IdentityRace != null && IdentityCaste != null) { EventLabel(frm, parent, ref location, "Identity Race:", IdentityRace); EventLabel(frm, parent, ref location, "Identity Race:", HistoricalFigure.Castes[IdentityCaste.Value]); } else { EventLabel(frm, parent, ref location, "Identity ID:", IdentityId.ToString()); } EventLabel(frm, parent, ref location, "Target Ent:", Entity_Target); }
public void TestCreateState() { IdentityId initiatorId = new IdentityId(); IPrincipal initiator = new ClaimsPrincipal(initiatorId.GetIdentity()); Task task = new Task(new TaskId(), TaskStatus.Created, string.Empty, string.Empty, Priority.Normal, false, DateTime.UtcNow, initiator.Identity, null, null, null); Thread.CurrentPrincipal = initiator; Assert.IsNotNull(task); Assert.AreEqual(TaskStatus.Created, task.Status); Assert.IsNull(task.ActualOwner); Assert.IsNotNull(task.Initiator); Assert.AreEqual(initiator.Identity, task.Initiator); Assert.AreEqual(Priority.Normal, task.Priority); Assert.AreEqual(TaskStatus.Created, task.Status); }
public CreateBusinessUserCommand(Guid id, IdentityId identityId, string location, string locale, string gender, Email email, string firstName, string middelName, string lastName) { Id = id; IdentityId = identityId; Location = location; Locale = locale; Gender = gender; Email = email; FirstName = firstName; MiddelName = middelName; LastName = lastName; }
internal override void Export(string table) { base.Export(table); table = GetType().Name; var vals = new List <object> { Id, HfId_Trickster.DBExport(), EntityId_Target.DBExport(), IdentityId.DBExport(), HfId_Identity.DBExport(), IdentityName.DBExport(), IdentityRace.DBExport(), IdentityCaste.DBExport(HistoricalFigure.Castes) }; Database.ExportWorldItem(table, vals); }
public void TestIdentitySurrogateCheckGroupIdentityUserAccount() { IdentityId id = new IdentityId(); Mock<IAccountFactory> mock=new Mock<IAccountFactory>(MockBehavior.Strict); mock.Setup(m => m.GetAccount(It.IsAny<IdentityId>())). Returns(() => new Account(id, "nativeId-user", "test", AccountType.User)).Verifiable(); _container.Register(Component.For(typeof(IAccountFactory)).UsingFactoryMethod(() => mock.Object)); IdentitySurrogate surrogate = new IdentitySurrogate(id); Assert.IsFalse(surrogate.IsGroupIdentity()); mock.Verify(m => m.GetAccount(It.IsAny<IdentityId>()),Times.Once()); }
public void TestIdentityIdIEquatableNotEqual() { IdentityId one=new IdentityId(); IdentityId two=new IdentityId(); Assert.IsFalse(one.Equals(two)); Assert.IsFalse(two.Equals(one)); Assert.IsFalse(one==two); Assert.IsFalse(two==one); Assert.IsTrue(one!=two); Assert.IsTrue(two != one); }
public void TestIdentityIdIEquatableEqual() { Guid id = Guid.NewGuid(); IdentityId one = new IdentityId(id); IdentityId two = new IdentityId(id); Assert.IsTrue(one.Equals(two)); Assert.IsTrue(two.Equals(one)); Assert.IsTrue(one == two); Assert.IsTrue(two == one); Assert.IsFalse(one != two); Assert.IsFalse(two != one); }
public void TestIdentityGetMappedIdFromSurrogate() { IdentityId id = new IdentityId(); Mock<IAccountFactory> mock = new Mock<IAccountFactory>(MockBehavior.Strict); mock.Setup(m => m.GetAccount(It.IsAny<IdentityId>())). Returns(() => new Account(id, "nativeId-group", "test", AccountType.Group)).Verifiable(); _container.Register(Component.For(typeof(IAccountFactory)).UsingFactoryMethod(() => mock.Object)); IdentitySurrogate surrogate = new IdentitySurrogate(id); IdentityId mappedId = surrogate.GetMappedId(); Assert.IsNotNull(mappedId); Assert.AreEqual(id,mappedId); mock.Verify(m => m.GetAccount(It.IsAny<IdentityId>()), Times.Never()); }
public void TestCreateSurrogateGetId() { IdentityId id=new IdentityId(); IdentitySurrogate surrogate=new IdentitySurrogate(id); IEnumerable<string> values =surrogate.GetValuesOfClaim(ClaimType.MappedId.ToString()); Assert.IsNotNull(values); Assert.AreEqual(1,values.Count()); Assert.AreEqual(id.ToString(),values.ElementAt(0)); }
/// <summary> /// Gets the by id. /// </summary> /// <param name="id">The id.</param> /// <returns></returns> public PersistentAccount GetById(IdentityId id) { return NHibernateHelper.RunInSession(_factory, s=> s.Load<PersistentAccount>(id.Id), (s,e)=>{}); }
internal static NetworkIdentity GetNetworkIdentityById(object identityId) { return(GetNetworkIdentityById(IdentityId.FromLong(long.Parse(identityId.ToString())))); }
/// <summary> /// Maps the account. /// </summary> /// <param name="authType">Type of the auth.</param> /// <param name="nativeId">The native id.</param> /// <param name="accountName">Name of the account.</param> /// <param name="displayName">The display name.</param> /// <returns></returns> public IdentityId MapAccount(string authType, string nativeId, string accountName, string displayName) { IdentityId id=new IdentityId(); _store[nativeId] = id; return id; }
public IEnumerable<Account> GetRoles(IdentityId id) { return new Account[] {}; }
public void TestIdentitySurrogateGetRoles() { IdentityId id = new IdentityId(); Mock<IAccountFactory> mock = new Mock<IAccountFactory>(MockBehavior.Strict); mock.Setup(m => m.GetAccount(It.IsAny<IdentityId>())). Returns(() => new Account(id, "nativeId-group", "test", AccountType.Group)).Verifiable(); mock.Setup(m => m.GetRoles(It.IsAny<IdentityId>())). Returns(() => new[] { new Account(new IdentityId(), "nativeId-ROLE-1", "role1", AccountType.Role), new Account(new IdentityId(), "nativeId-ROLE-2", "role2", AccountType.Role), new Account(new IdentityId(), "nativeId-ROLE-3", "role3", AccountType.Role), new Account(new IdentityId(), "nativeId-ROLE-4", "role4", AccountType.Role) }).Verifiable(); mock.Setup(m=>m.GetGroups(It.IsAny<IdentityId>())).Verifiable(); _container.Register(Component.For(typeof(IAccountFactory)).UsingFactoryMethod(() => mock.Object)); IdentitySurrogate surrogate = new IdentitySurrogate(id); IEnumerable<IIdentity> roles = surrogate.InRoles(); Assert.IsNotNull(roles); Assert.AreEqual(4,roles.Count()); foreach (IIdentity identity in roles) { Assert.IsTrue(identity is IdentitySurrogate); } mock.Verify(m => m.GetRoles(It.IsAny<IdentityId>()), Times.Once()); mock.Verify(m => m.GetAccount(It.IsAny<IdentityId>()), Times.Never()); mock.Verify(m => m.GetGroups(It.IsAny<IdentityId>()), Times.Never()); }
public Account GetAccount(IdentityId id) { Account acc; if(!_mapStorage.TryGetValue(id.Id, out acc)) throw new AccountNotMapped(); return acc; }
public void TestSuspendedToReversedActualOwner() { IdentityId actualId = new IdentityId(); ILoggingService loggingService = SetupLoggerMock(new List<TaskHistoryEvent>()); Task task = new Task( new TaskId(), TaskStatus.Reserved, string.Empty, string.Empty, Priority.Normal, false, DateTime.UtcNow, new IdentityId().GetIdentity(), DateTime.UtcNow, null, actualId.GetIdentity()) { LoggingService = loggingService }; IPrincipal actualOwner = new ClaimsPrincipal(actualId.GetIdentity()); Thread.CurrentPrincipal = actualOwner; task.Suspend(); Assert.AreEqual(TaskStatus.Suspended, task.Status); Assert.AreEqual(actualId.GetIdentity(), task.ActualOwner); task.Resume(); Assert.AreEqual(TaskStatus.Reserved, task.Status); Assert.AreEqual(actualId.GetIdentity(), task.ActualOwner); Assert.IsNotNull(task.History); Assert.AreEqual(2, task.History.Count()); TaskHistoryEvent history = task.History.ElementAt(0); Assert.IsNotNull(history); Assert.AreEqual(TaskStatus.Reserved, history.OldStatus); Assert.AreEqual(TaskStatus.Suspended, history.NewStatus); Assert.AreEqual(actualId, history.UserId); history = task.History.ElementAt(1); Assert.IsNotNull(history); Assert.AreEqual(TaskStatus.Suspended, history.OldStatus); Assert.AreEqual(TaskStatus.Reserved, history.NewStatus); Assert.AreEqual(actualId, history.UserId); }
public BroadcastPacket(IdentityId id, string methodName, bool shouldInvokeSynchronously, object[] methodArgs) : base(PacketId.BroadcastMethod, id, methodName, shouldInvokeSynchronously, methodArgs) { }
public void TestReservedForwardActualOwner() { IdentityId potentialOwner = new IdentityId(); IdentityId actualId = new IdentityId(); _mapStorage[potentialOwner.Id] = new Account(potentialOwner, "s-1-2-3-4-5", "auth", AccountType.User); ILoggingService loggingService = SetupLoggerMock(new List<TaskHistoryEvent>()); Task task = new Task( new TaskId(), TaskStatus.Reserved, string.Empty, string.Empty, Priority.Normal, false, DateTime.UtcNow, new IdentityId().GetIdentity(), DateTime.UtcNow, null, actualId.GetIdentity()) { LoggingService = loggingService }; IPrincipal actualOwner = new ClaimsPrincipal(actualId.GetIdentity()); Thread.CurrentPrincipal = actualOwner; task.Forward(potentialOwner.GetIdentity()); Assert.AreEqual(TaskStatus.Ready, task.Status); Assert.IsNotNull(task.ActualOwner); Assert.AreEqual(potentialOwner, task.ActualOwner.GetMappedId()); Assert.IsNotNull(task.History); Assert.AreEqual(1, task.History.Count()); TaskHistoryEvent history = task.History.ElementAt(0); Assert.IsNotNull(history); Assert.AreEqual(TaskStatus.Reserved, history.OldStatus); Assert.AreEqual(TaskStatus.Ready, history.NewStatus); Assert.AreEqual(actualId, history.UserId); Assert.AreEqual(actualId, history.StartOwner); Assert.AreEqual(potentialOwner, history.EndOwner); }
public void TestNominateIndividual() { IdentityId potentialOwner = new IdentityId(); IdentityId businessAdministrator = new IdentityId(); _mapStorage[potentialOwner.Id] = new Account(potentialOwner, "s-1-2-3-4-5", "auth", AccountType.User); ILoggingService loggingService = SetupLoggerMock(new List<TaskHistoryEvent>()); Task task = new Task( new TaskId(), TaskStatus.Created, string.Empty, string.Empty, Priority.Normal, false, DateTime.UtcNow, new IdentityId().GetIdentity(), DateTime.UtcNow, null, null) { LoggingService = loggingService }; IPrincipal actualOwner = new ClaimsPrincipal(businessAdministrator.GetIdentity()); Thread.CurrentPrincipal = actualOwner; task.BusinessAdministrators.Add(businessAdministrator.GetIdentity()); task.Nominate(potentialOwner.GetIdentity()); Assert.AreEqual(TaskStatus.Reserved, task.Status); Assert.IsNotNull(task.ActualOwner); Assert.AreEqual(potentialOwner, task.ActualOwner.GetMappedId()); Assert.IsTrue(task.PotentialOwners.Contains(potentialOwner.GetIdentity())); Assert.IsNotNull(task.History); Assert.AreEqual(1, task.History.Count()); TaskHistoryEvent history = task.History.ElementAt(0); Assert.IsNotNull(history); Assert.AreEqual(TaskStatus.Created, history.OldStatus); Assert.AreEqual(TaskStatus.Reserved, history.NewStatus); Assert.AreEqual(businessAdministrator, history.UserId); Assert.AreEqual(null,history.StartOwner); Assert.AreEqual(potentialOwner, history.EndOwner); }
/// <summary> /// Gets the list of roles for the account. /// </summary> /// <param name="mappedId">The mapped id.</param> /// <returns></returns> public IEnumerable<Account> GetRoles(IdentityId mappedId) { throw new NotImplementedException(); }
public void TestEnsureSimpePropertySearch() { Mock<TaskExpressionTranslatorBase> mock = new Mock<TaskExpressionTranslatorBase> { CallBase = true }; IIdentity initiatorIdentity = new IdentityId(new Guid("56FDB6D4-D3AA-4C97-964A-6E8660A92FBC")).GetIdentity(); DateTime now = DateTime.UtcNow; mock.Protected().Setup("QueryStatus", ItExpr.Is<Operation>(o=>o==Operation.Equals), ItExpr.Is<object>(v => (TaskStatus)v == TaskStatus.Ready)).Verifiable(); mock.Protected().Setup("QueryPriority", ItExpr.Is<Operation>(o=>o==Operation.Equals), ItExpr.Is<object>(v => (Priority)v == Priority.Normal)).Verifiable(); mock.Protected().Setup("QueryId", ItExpr.Is<Operation>(o=>o==Operation.Equals), ItExpr.Is<object>(v => (TaskId) v ==new TaskId(new Guid("56FDB6D4-D3AA-4C97-964A-6E8660A92FBC")))).Verifiable(); mock.Protected().Setup("QueryCreated", ItExpr.Is<Operation>(o=>o==Operation.LessOrEquals), ItExpr.Is<object>(v => ((DateTime)v).Equals(now - new TimeSpan(20, 0, 0)))).Verifiable(); mock.Protected().Setup("QueryStarted", ItExpr.Is<Operation>(o=>o==Operation.GreaterOrEquals), ItExpr.Is<object>(v => ((DateTime)v).Equals(now-new TimeSpan(10,0,0)))).Verifiable(); mock.Protected().Setup("QueryCompleted", ItExpr.Is<Operation>(o=>o==Operation.Less), ItExpr.Is<object>(v =>((DateTime)v).Equals(now))).Verifiable(); mock.Protected().Setup("QueryTaskOutcome", ItExpr.Is<Operation>(o=>o==Operation.Equals), ItExpr.Is<object>(v => (string)v == "success")).Verifiable(); mock.Protected().Setup("QueryInitiator", ItExpr.Is<Operation>(o=>o==Operation.Equals), ItExpr.Is<object>(v => ((IIdentity)v).GetMappedId().Id == new Guid("56FDB6D4-D3AA-4C97-964A-6E8660A92FBC"))).Verifiable(); mock.Protected().Setup("QueryActualOwner", ItExpr.Is<Operation>(o=>o==Operation.NotEqual), ItExpr.Is<object>(v => v == null)).Verifiable(); mock.Setup(m => m.Execute()).Returns(new List<Task>()); Mock<TaskQueryContext> ctxMock=new Mock<TaskQueryContext>{CallBase = true}; ctxMock.Protected().Setup<TaskExpressionTranslatorBase>("InstantiateTranslator").Returns(mock.Object); QuerableTaskService tasks = new QuerableTaskService(ctxMock.Object); var t = from task in tasks where task.Priority == GetPriority() && task.Status == TaskStatus.Ready && task.Id == new TaskId(new Guid("56FDB6D4-D3AA-4C97-964A-6E8660A92FBC")) && task.Created<=now-new TimeSpan(20,0,0) && task.Started>=now-new TimeSpan(10,0,0) && task.Completed<now && task.TaskOutcome=="success" && task.Initiator == initiatorIdentity && task.ActualOwner!=null select task; foreach (Task task in t) { //execute the query } // verify executions mock.Protected().Verify("QueryStatus", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.Equals), ItExpr.Is<object>(v => (TaskStatus)v == TaskStatus.Ready)); mock.Protected().Verify("QueryPriority", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.Equals), ItExpr.Is<object>(v => (Priority)v == Priority.Normal)); mock.Protected().Verify("QueryId", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.Equals), ItExpr.Is<object>(v => (TaskId)v == new TaskId(new Guid("56FDB6D4-D3AA-4C97-964A-6E8660A92FBC")))); mock.Protected().Verify("QueryCreated", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.LessOrEquals), ItExpr.Is<object>(v => ((DateTime)v).Equals(now - new TimeSpan(20, 0, 0)))); mock.Protected().Verify("QueryStarted", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.GreaterOrEquals), ItExpr.Is<object>(v => ((DateTime)v).Equals(now - new TimeSpan(10, 0, 0)))); mock.Protected().Verify("QueryCompleted", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.Less), ItExpr.Is<object>(v => ((DateTime)v).Equals(now))); mock.Protected().Verify("QueryTaskOutcome", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.Equals), ItExpr.Is<object>(v => (string)v == "success")); mock.Protected().Verify("QueryInitiator", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.Equals), ItExpr.Is<object>(v => ((IIdentity)v).GetMappedId().Id == new Guid("56FDB6D4-D3AA-4C97-964A-6E8660A92FBC"))); mock.Protected().Verify("QueryActualOwner", Times.Once(), ItExpr.Is<Operation>(o => o == Operation.NotEqual), ItExpr.Is<object>(v => v == null)); }
public NetworkIdentityBasePacket(PacketId packetId, bool shouldInvokeSynchronously, IdentityId networkIdentityId) : base(packetId, shouldInvokeSynchronously) { NetworkIdentityId = networkIdentityId; Data.Add(NetworkIdentityId.Id); }
public CommandPacket(IdentityId id, string methodName, bool shouldInvokeSynchronously, object[] methodArgs) : base(PacketId.Command, id, methodName, shouldInvokeSynchronously, methodArgs) { }
internal SpawnObjectPacket(bool shouldInvokeSynchronously, Type instance, IdentityId id, EndPointId ownerId, bool spawnDuringSync, params string[] spawnParams) : base(PacketId.SpawnObject, shouldInvokeSynchronously, id, instance, ownerId, spawnDuringSync, spawnParams) { }
public NetworkIdentityBasePacket(PacketId packetId, List <object> args) : base(packetId, args) { NetworkIdentityId = IdentityId.FromLong(Convert.ToInt64(args[0])); args.RemoveAt(0); }
protected override void InitIdentityLocally(NetworkIdentity identity, EndPointId ownerID, IdentityId id, bool spawnDuringSync, params object[] valuesByFields) { identity.isInServer = false; base.InitIdentityLocally(identity, ownerID, id, spawnDuringSync, valuesByFields); }
protected virtual void InitIdentityLocally(NetworkIdentity identity, EndPointId ownerId, IdentityId id, bool spawnDuringSync, params object[] valuesByFields) { identity.NetworkBehavior = this; identity.LocalEndPoint = localEndPointId; identity.OwnerId = ownerId; identity.Id = id; identity.hasAuthority = ownerId == this.localEndPointId; identity.isServerAuthority = ownerId == serverEndPointId; if (valuesByFields != null && valuesByFields.Length != 0) { Dictionary <string, string> valuesByFieldsDict = valuesByFields.Select(v => v.ToString().Split('+')).ToDictionary(k => k[0], v => v[1]); SetObjectFieldsByValues(identity, valuesByFieldsDict); identity.hasFieldsBeenInitialized = true; } identity.AddToEntities(); if (!spawnDuringSync) { CallIdentityEvent(identity); } }