/// <summary> /// Initializes a new instance of the <see cref="AccountServer"/> class. /// </summary> public AccountServer(IClock clock) { this.clock = clock; this.activeAccounts = new Dictionary<int, ActiveAccount>(256); this.currentSessionId = new AtomicInteger(0); }
public void CompareExchange_Should_Return_Old_Value_When_Comparand_Matches() { var i = new AtomicInteger(123); var old = i.CompareExchange(123, 321); old.Should().Be(123); }
public void CompareExchange_Should_Return_Current_Value_When_Comparand_Does_Not_Match() { var i = new AtomicInteger(123); var current = i.CompareExchange(234, 432); current.Should().Be(123); }
public void CompareExchange_Should_Not_Set_New_Value_When_Comparand_Does_Not_Match() { var i = new AtomicInteger(123); i.CompareExchange(234, 432); i.Value.Should().Be(123); }
public void Decrement_Should_Return_Decreased_Value() { var i = new AtomicInteger(123); var current = i.Decrement(); current.Should().Be(122); }
public void CompareExchange_Should_Set_New_Value_When_Comparand_Matches() { var i = new AtomicInteger(123); i.CompareExchange(123, 321); i.Value.Should().Be(321); }
public void Decrement_Should_Set_Decreased_Value() { var i = new AtomicInteger(123); i.Decrement(); i.Value.Should().Be(122); }
/// <summary> /// Extracts a <see cref="Int32"/> from an instance of <see cref="AtomicInteger"/>. /// </summary> /// <param name="atomicInteger">The <see cref="AtomicInteger"/> to extract the value of.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="atomicInteger" /> is <see langword="null"/>. /// </exception> /// <returns>the value of the <see cref="AtomicInteger"/>.</returns> public static int ToInt32(AtomicInteger atomicInteger) { if (atomicInteger == null) { throw new InvalidCastException(); } return atomicInteger.value; }
/// <summary> /// Initializes a new instance of the <see cref="ClientBase" /> class. /// </summary> /// <param name="serverSession">The network session to bind the instance to.</param> /// <param name="packetFactory">The <see cref="IPacketFactory" /> to use for this client.</param> /// <param name="logger">The logger to use for this client.</param> /// <exception cref="ArgumentNullException">Thrown if any of the parameters is <see langword="null" />.</exception> protected ClientBase(IServerSession serverSession, IPacketFactory packetFactory, ILogger logger) { Guard.NotNull(() => serverSession, serverSession); Guard.NotNull(() => packetFactory, packetFactory); this.isDisposed = false; this.sentPings = new AtomicInteger(0); this.ServerSession = this.InitializeSession(serverSession); this.PacketFactory = packetFactory; this.Logger = logger; this.keepAliveTimer = this.InitializeTimer(); this.keepAliveTimer.Start(); }
public void ToInt32_Should_Return_Value_As_Int32() { var i = new AtomicInteger(123); i.ToInt32().Should().Be(123); }
public void ExchangeWith_Should_Return_Old_Value() { var i = new AtomicInteger(123); var old = i.ExchangeWith(321); old.Should().Be(123); }
/// <summary> /// Initializes a new instance of the <see cref="ActiveChannel"/> class. /// </summary> public ActiveChannel() { this.channelLoad = 0; }
public void Implicit_Cast_From_Int32_Should_Set_Value() { AtomicInteger i = 123; i.Value.Should().Be(123); }
public void Static_ToInt32_Should_Throw_On_Null() { Action action = () => AtomicInteger.ToInt32(null); action.ShouldThrow <InvalidCastException>(); }
public void Static_ToInt32_Should_Return_Value_As_Int32() { var i = new AtomicInteger(123); AtomicInteger.ToInt32(i).Should().Be(123); }
public void Constructor_Should_Set_Value() { var i = new AtomicInteger(123); i.Value.Should().Be(123); }
public void Explicit_Cast_To_Int32_Should_Return_Value() { var i = new AtomicInteger(123); var cast = (int)i; cast.Should().Be(123); }
public void Increment_Should_Set_Increased_Value() { var i = new AtomicInteger(123); i.Increment(); i.Value.Should().Be(124); }
public void ExchangeWith_Should_Set_New_Value() { var i = new AtomicInteger(123); i.ExchangeWith(321); i.Value.Should().Be(321); }