Exemplo n.º 1
0
        public void AfterCreateArtefact_MyPeersKnowIHaveIt()
        {
            Interconnect(MyActor, OtherActor);
            var artefact = MyActor.CreateArtefact(Artefact.Name);

            Assert.True(OtherAccount.GetPeer(MyId).HasArtefact(artefact.Id));
        }
Exemplo n.º 2
0
        public void CanCreateTwoDifferentArtefacts()
        {
            Interconnect(MyActor, OtherActor);

            var a1 = MyActor.CreateArtefact(Artefact.Name);
            var a2 = MyActor.CreateArtefact(AnotherArtefact.Name);

            Assert.True(OtherAccount.GetPeer(MyId).HasArtefact(a1.Id));
            Assert.True(OtherAccount.GetPeer(MyId).HasArtefact(a2.Id));
        }
Exemplo n.º 3
0
        public void WhenCreatingManyTransientArtefacts_IdsAreReused()
        {
            var first = MyActor.CreateArtefact("abc");

            ((Account)MyAccount)._transientArtefactCount = int.MaxValue - 1;
            MyActor.CreateArtefact("abc");
            var last = MyActor.CreateArtefact("abc");

            Assert.Equal(first.Id.Number, last.Id.Number);
        }
Exemplo n.º 4
0
        public void AfterOtherAccountCreateAndDestroyArtefact_ICanCreateSameArtefact()
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            var a1 = OtherActor.CreateArtefact(Artefact.Name);

            OtherActor.DestroyArtefact(a1.Id);

            var a2 = MyActor.CreateArtefact(Artefact.Name);

            Assert.True(ThirdAccount.GetPeer(MyId).HasArtefact(a2.Id));
        }
Exemplo n.º 5
0
        public void IfBuyerDontBelieveSellerHasArtefact_TransactionIsNotAccepted()
        {
            Interconnect(MyActor, OtherActor);
            var artefact = MyActor.CreateArtefact(Artefact.Name);

            OtherActor.CounterfeitArtefact(artefact);
            var key = StartTransaction(MyActor, OtherActor, artefact);

            Assert.NotNull(key);
            Assert.NotEmpty(key);
            Assert.False(OtherActor.AcceptTransaction(key));
        }
Exemplo n.º 6
0
        public void WhenActorCreateArtefact_IdIsBasedOnAccountIdWithIncrementalNumber()
        {
            var a1 = MyActor.CreateArtefact("abc");
            var a2 = MyActor.CreateArtefact("abc");
            var b1 = OtherActor.CreateArtefact("abc");
            var b2 = OtherActor.CreateArtefact("abc");

            Assert.Equal(MyAccount.Id / 1, a1.Id);
            Assert.Equal(MyAccount.Id / 2, a2.Id);
            Assert.Equal(OtherAccount.Id / 1, b1.Id);
            Assert.Equal(OtherAccount.Id / 2, b2.Id);
        }
Exemplo n.º 7
0
        public void WhenPeerDestroyArtefactThatPeerDoesntOwn_PeerLoosesTrust()
        {
            var artefact = MyActor.CreateArtefact(Artefact.Name);

            OtherActor.CounterfeitArtefact(artefact);
            Interconnect(MyActor, OtherActor);
            var trustBefore = MyAccount.GetTrust(OtherId);

            OtherActor.DestroyArtefact(artefact.Id);

            var expectedTrustAfter = trustBefore.Decrease(DestroyOthersArtefactDistrustFactor);

            Assert.Equal(expectedTrustAfter, MyAccount.GetTrust(OtherId));
        }
Exemplo n.º 8
0
        public void AfterCreateArtefact_SelfHasArtefact()
        {
            var artefact = MyActor.CreateArtefact(Artefact.Name);

            Assert.True(MyAccount.Self.HasArtefact(artefact.Id));
        }
Exemplo n.º 9
0
 public void ThrowsWhenCreatingTooManyResilientArtefacts()
 {
     ((Account)MyAccount)._resilientArtefactCount = int.MaxValue - 1;
     MyActor.CreateArtefact("abc", true);
     Assert.Throws <OutOfBounds <uint> >(() => MyActor.CreateArtefact("abc", true));
 }
Exemplo n.º 10
0
        public void WhenCreateResilientArtefact_NumberIsAtLeastIntMax()
        {
            var artefact = MyActor.CreateArtefact("abc", true);

            Assert.InRange(artefact.Id.Number, (uint)int.MaxValue, uint.MaxValue);
        }
Exemplo n.º 11
0
        public void WhenCreateTransientArtefact_NumberIsLessThanIntMax()
        {
            var artefact = MyActor.CreateArtefact("abc");

            Assert.InRange(artefact.Id.Number, (uint)0, (uint)(int.MaxValue - 1));
        }