public void OneToManyMapper_GetChildrenEmpty() { var oneToManyMapper = new OneToManyMapper(); var childList = oneToManyMapper.GetChildren(0); Assert.Empty(childList); }
public void WhenForceClassRelationToIncompatibleTypeThenThrows() { var hbm = new HbmOneToMany(); var mapper = new OneToManyMapper(typeof(IMyInterface), hbm, null); Executing.This(() => mapper.Class(typeof(Whatever))).Should().Throw <ArgumentOutOfRangeException>(); }
public void CanAssignEntityName() { var hbm = new HbmOneToMany(); var mapper = new OneToManyMapper(typeof(MyClass), hbm, null); mapper.EntityName("myname"); hbm.EntityName.Should().Be("myname"); }
public void CanAssignNotFoundMode() { var hbm = new HbmOneToMany(); var mapper = new OneToManyMapper(typeof(MyClass), hbm, null); mapper.NotFound(NotFoundMode.Ignore); hbm.NotFoundMode.Should().Be(HbmNotFoundMode.Ignore); }
public void CanForceClassRelation() { var hbm = new HbmOneToMany(); var mapper = new OneToManyMapper(typeof(IMyInterface), hbm, null); mapper.Class(typeof(MyClass)); hbm.Class.Should().Contain("MyClass").And.Not.Contain("IMyInterface"); }
public void OneToManyMapper_GetParent0() { var child = new Child(1); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.childList.Add(child); int parentForChild = oneToManyMapper.GetParent(1); Assert.Equal(0, parentForChild); }
public void OneToManyMapper_Add(int parentId, int childId) { var parent = new Parent(parentId); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.parentList.Add(parent); oneToManyMapper.Add(parentId, childId); Assert.True(parent.children.Contains(childId), $"Children is not added to this parent"); }
public void OneToManyMapper_GetParent(int parentId, int childId) { var parent = new Parent(parentId); var child = new Child(childId); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.parentList.Add(parent); oneToManyMapper.childList.Add(child); oneToManyMapper.Add(parentId, childId); int parentForChild = oneToManyMapper.GetParent(childId); Assert.Equal(parentForChild, parentId); }
public void OneToManyMapper_GetChildren(int parentId, int childId) { var parent = new Parent(parentId); var child = new Child(childId); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.parentList.Add(parent); oneToManyMapper.childList.Add(child); oneToManyMapper.Add(parentId, childId); var childList = oneToManyMapper.GetChildren(parentId); Assert.True(childList.Count() == 1, $"Value returned is not of type List"); }
public void OneToManyMapper_RemoveChild(int parentId, int childId) { var parent = new Parent(parentId); var child = new Child(childId); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.parentList.Add(parent); oneToManyMapper.childList.Add(child); oneToManyMapper.Add(parentId, childId); oneToManyMapper.RemoveChild(childId); Assert.True(oneToManyMapper.childList.Count == 0, $"Child was not removed from childList"); Assert.True(parent.children.Count == 0, $"Child was not removed from childList"); }
//========== Constructor ====================================================================================== public TextChatHubCtrl(IHubConnectionContext <ITextChatHubClient> clients, TextChatController chatController) { Clients = clients; RoomsConnections = new RoomsConnectionsManager(); UsersConnections = new OneToManyMapper <UserId, ConnectionId>(); ChatCtrl = chatController; LastSeenConnections = new Dictionary <ConnectionId, DateTime>(); // Handle Chat Controller Events ChatCtrl.OnUserJoined += (user) => Send(UsersConnections.Values, new AddUserInvoker(user)); ChatCtrl.OnUserLeft += (userId) => Send(UsersConnections.Values, new RemoveUserInvoker(userId)); ChatCtrl.OnUserJoinedRoom += (roomId, userId) => Send(RoomsConnections.GetConnections(roomId), new AddUserToInvoker(roomId, userId)); ChatCtrl.OnUserLeftRoom += (roomId, userId) => Send(RoomsConnections.GetConnections(roomId), new RemoveUserFromInvoker(roomId, userId)); ChatCtrl.OnCountOfUsersUpdated += (roomId, count) => Send(UsersConnections.Values, new UpdateCountOfUsersInvoker(roomId, count)); ChatCtrl.OnUserStartedTyping += (roomId, userId) => Send(RoomsConnections.GetConnections(roomId), new MarkUserAsTypingInvoker(roomId, userId)); ChatCtrl.OnUserStoppedTyping += (roomId, userId) => Send(RoomsConnections.GetConnections(roomId), new UnmarkUserAsTypingInvoker(userId)); ChatCtrl.OnUserRequestedAudioCall += (roomId, userId) => Send(GetPartnerConnections(roomId, userId), new RequestAudioCallInvoker(roomId)); ChatCtrl.OnUserCancelledAudioCall += (roomId, userId) => Send(GetPartnerConnections(roomId, userId), new CancelAudioCallInvoker(roomId, userId)); ChatCtrl.OnUserDeclinedAudioCall += (roomId, reason, connId) => Send(GetRelatedConnections(roomId, connId), new DeclineAudioCallInvoker(roomId, reason)); ChatCtrl.OnUserHangoutedAudioCall += (roomId, userId) => Send(GetRelatedConnections(roomId), new HangoutAudioCallInvoker(roomId, userId)); ChatCtrl.OnAudioCallConnected += (roomId, userId) => Send(GetRelatedConnections(roomId), new AudioCallConnectedInvoker(roomId, userId)); ChatCtrl.OnPostedMessage += (msg) => { Send(msg.RoomId.IsPrivate() ? GetPartnerAndActiveConnections(msg.RoomId, msg.UserId, msg.ConnectionId) : RoomsConnections.GetConnections(msg.RoomId, msg.ConnectionId), new AddMessageInvoker(msg)); }; ChatCtrl.OnUserIdle += (userId) => Send(UsersConnections.GetFromKey(userId), new SetUserIdleInvoker(userId)); // Start connection heartbeat check var heartBeatTimer = new BetterTimer(OnLogHeartbeatError) { AutoReset = true }; heartBeatTimer.Start(null, HeartbeatCheck, HeartbeatCheckInterval); // Start connection heartbeat check var healthReportTimer = new BetterTimer(OnLogHealthReportError) { AutoReset = true }; healthReportTimer.Start(null, PublishHealthReport, HealthReportInterval); }
public void TestSetup() { _sut = new OneToManyMapper(); }