public void WhenDecreaseTrustWithFactor_OutOfBounds_ThrowsOutOfBoundsException(
     float trustBefore, float factor)
 {
     MyActor.Connect(OtherId);
     MyAccount.SetTrust(OtherId, (SignedWeight)trustBefore);
     Assert.Throws <OutOfBounds <float> >(() => MyAccount.DecreaseTrust(OtherId, (Weight)factor));
 }
        public void AfterIConnectWithAgent_IAmConnectedToAgent()
        {
            MyActor.Connect(OtherId);

            Assert.NotNull(MyAccount.GetPeer(OtherId));
            Assert.True(MyAccount.IsConnectedTo(OtherId));
        }
 public void CanIncreaseTrustWithFactor(float trustBefore, float factor, float trustAfter)
 {
     MyActor.Connect(OtherId);
     MyAccount.SetTrust(OtherId, (SignedWeight)trustBefore);
     MyAccount.IncreaseTrust(OtherId, (Weight)factor);
     Assert.Equal((SignedWeight)trustAfter, MyAccount.GetTrust(OtherId));
 }
Example #4
0
        public void WhenUpdatedWithInvalidSignature_ThrowsInvalidOperationException()
        {
            MyActor.Connect(OtherId);
            var otherAgent = _network.FindAgent(OtherId);

            Assert.Throws <InvalidOperationException>(
                () => _network.SendAction(MyId, OtherId, _cryptography.Sign(new NoAction())));
        }
        public void CanSetAndGetTrustOfPeer(float trustValue)
        {
            var trust = (SignedWeight)trustValue;

            MyActor.Connect(OtherId);
            MyAccount.SetTrust(OtherId, trust);
            Assert.Equal(trust, MyAccount.GetTrust(OtherId));
        }
        public void AfterSetMoney_PeerHasMoney(float initialMoney, float setMoney, float hasMoney)
        {
            MyActor.Connect(OtherId);
            MyAccount.SetMoney(OtherId, (Money)initialMoney);

            MyAccount.SetMoney(OtherId, (Money)setMoney);

            Assert.Equal(hasMoney, MyAccount.GetMoney(OtherId));
        }
Example #7
0
        public void WhenConnectPeer_PeerIsSynced()
        {
            Interconnect(MyActor, OtherActor);
            Interconnect(ThirdActor, OtherActor);
            OtherAccount.SetMoney(ThirdId, (Money)100);
            MyAccount.SetTrust(OtherId, SignedWeight.Max);

            MyActor.Connect(ThirdId);

            Assert.Equal((Money)50, MyAccount.GetMoney(ThirdId));
        }
        public void AfterIEndorcedPeer_TrustOfPeerIncreaseWithEndorcementFactor(float trustValueBefore)
        {
            var trustBefore = (SignedWeight)trustValueBefore;

            MyActor.Connect(OtherId);
            MyAccount.SetTrust(OtherId, trustBefore);

            MyActor.Endorce(OtherId);

            Assert.Equal(trustBefore.Increase(EndorcementTrustFactor), MyAccount.GetTrust(OtherId));
        }
 public void AfterMyPeerConnectWithMe_IAmUpdatedOfPeerConnection()
 {
     MyActor.Connect(OtherId);
     OtherActor.Connect(MyId);
     Assert.True(MyAccount.GetPeer(OtherId).IsConnectedTo(MyId));
 }
 public void AfterIConnectWithAgent_AgentIsNotConnectedToMe()
 {
     MyActor.Connect(OtherId);
     Assert.False(OtherAccount.IsConnectedTo(MyId));
     Assert.False(MyAccount.GetPeer(OtherId).IsConnectedTo(MyId));
 }
 public void AfterConnectedAgent_TrustIs_Zero()
 {
     MyActor.Connect(OtherId);
     Assert.Equal(0f, MyAccount.GetTrust(OtherId));
 }
 public void WhenSetTrustOutOfBounds_ThrowsOutOfBoundsException(float trust)
 {
     MyActor.Connect(OtherId);
     Assert.Throws <OutOfBounds <float> >(() => MyAccount.SetTrust(OtherId, (SignedWeight)trust));
 }
 public void NewPeerHasNoMoney()
 {
     MyActor.Connect(OtherId);
     Assert.Equal((Money)0, MyAccount.GetPeer(OtherId).Money);
 }
 public void WhenSetNegativeMoney_ThrowsOutOfBounds()
 {
     MyActor.Connect(OtherId);
     Assert.Throws <OutOfBounds <float> >(() => MyAccount.SetMoney(OtherId, (Money)(-0.00001f)));
 }