예제 #1
0
        public async Task discard_and_reassign_outgoing()
        {
            var list = new List <Envelope>();

            for (var i = 0; i < 10; i++)
            {
                var envelope = ObjectMother.Envelope();
                envelope.Status = TransportConstants.Outgoing;

                list.Add(envelope);
            }

            await ThePersistence.StoreOutgoing(list.ToArray(), 111);

            var toDiscard  = new[] { list[2], list[3], list[7] };
            var toReassign = new[] { list[1], list[4], list[6] };

            await ThePersistence.DiscardAndReassignOutgoing(toDiscard, toReassign, 444);

            var stored = ThePersistence.AllOutgoingEnvelopes();

            stored.Length.ShouldBe(7);

            stored.Any(x => x.Id == list[2].Id).ShouldBeFalse();
            stored.Any(x => x.Id == list[3].Id).ShouldBeFalse();
            stored.Any(x => x.Id == list[7].Id).ShouldBeFalse();

            stored.Single(x => x.Id == list[1].Id).OwnerId.ShouldBe(444);
            stored.Single(x => x.Id == list[4].Id).OwnerId.ShouldBe(444);
            stored.Single(x => x.Id == list[6].Id).OwnerId.ShouldBe(444);
        }