Exemple #1
0
        public void GetAddressByCode_AddressExists_ReturnsAddressWithCodeAndAssociationId()
        {
            var view = new GetAddressesView();

            _addressAddedToAssociationEvent.Id    = "address123";
            _codeAssignedToAddressEvent.AddressId = "address123";
            _codeAssignedToAddressEvent.Code      = "code123";

            view.Handle(null, _addressAddedToAssociationEvent);
            view.Handle(null, _codeAssignedToAddressEvent);

            view.GetAddressByCode("code123").AssociationId.ShouldBe("ass123");
            view.GetAddressByCode("code123").Codes.ShouldContain("code123");
            view.GetAddressByCode("code123").Id.ShouldBe("address123");
        }
Exemple #2
0
        public void GetAddressByCode_AddressDoesNotExists_ReturnsNull()
        {
            var view = new GetAddressesView();

            view.Handle(null, _addressAddedToAssociationEvent);
            view.Handle(null, _codeAssignedToAddressEvent);

            view.GetAddressByCode("code123").ShouldBe(null);
        }
Exemple #3
0
        public void GetAddressByCode_AddressHasBeenRemovedFromAssociation_ReturnsNull()
        {
            var view = new GetAddressesView();

            _addressAddedToAssociationEvent.Id     = "address123";
            _codeAssignedToAddressEvent.AddressId  = "address123";
            _codeAssignedToAddressEvent.Code       = "code123";
            _addressRemovedFromAssociationEvent.Id = "address123";

            view.Handle(null, _addressAddedToAssociationEvent);
            view.Handle(null, _codeAssignedToAddressEvent);
            view.Handle(null, _addressRemovedFromAssociationEvent);

            view.GetAddressByCode("code123").ShouldBe(null);
        }