public async Task ShouldCreateAddress()
        {
            var status = Task <Unit> .FromResult(await sut.Handle(new CreateAddressCommand {
                Street = GConst.ValidName, Number = GConst.ValidAddressNumber, CityId = cityId
            }, CancellationToken.None));

            Assert.Null(status.Exception);
            Assert.Equal(GConst.SuccessStatus, status.Status.ToString());
            Assert.Equal(GConst.ValidCount, context.Addresses.Count());
        }
        public async Task CreateAddress_UserDoesNotExist_ShouldThrowException()
        {
            var sut = new CreateAddressCommandHandler(_context);

            await sut.Handle(new CreateAddressCommand { UserId = Guid.NewGuid() }, CancellationToken.None)
            .ShouldThrowAsync <NotFoundException>();
        }
        public async Task CreateAddress_WhenCalled_ShouldCreateAddress()
        {
            var sut = new CreateAddressCommandHandler(_context);
            var addressCountBeforeAct = _context.Address.ToList().Count;
            var currentUser           = _context.User.First();

            await sut.Handle(
                new CreateAddressCommand
            {
                UserId   = currentUser.Id, PrimaryAddress = false, City = "Glasgow", PhoneNumber = "0141 000 0000",
                Postcode = "G55 5RR", Street = "Main Street"
            }, CancellationToken.None);

            var addressCountAfterAct = _context.Address.ToList().Count;

            addressCountAfterAct.ShouldBe(addressCountBeforeAct + 1);
        }
        public async Task CreateAddress_UserAlreadyHasAPrimaryAddress_ShouldSetCurrentPrimaryAddressToFalse()
        {
            var sut                   = new CreateAddressCommandHandler(_context);
            var currentUser           = _context.User.First();
            var addressCountBeforeAct = _context.Address.ToList().Count;
            var oldPrimaryAddress     =
                _context.Address.First(x => x.UserId == currentUser.Id && x.PrimaryAddress);

            var command = new CreateAddressCommand {
                City = "Glasgow", UserId = currentUser.Id, PrimaryAddress = true
            };
            await sut.Handle(command, CancellationToken.None);

            oldPrimaryAddress.PrimaryAddress.ShouldBe(false);
            _context.Address.First(x => x.UserId == currentUser.Id && x.PrimaryAddress).City.ShouldBe("Glasgow");
            _context.Address.Count().ShouldBe(addressCountBeforeAct + 1);
        }