public Task ChangeRecipient(string name, AddressValueObject address) { Recipient.ChangeName(name); Recipient.ChangeAddress(address); return(Task.CompletedTask); }
public async Task AddressValueObjectMustHaveComplementWithValidLengthSpecifcation_IsSatisfiedBy_Success() { _ = await RunWithTelemetryAsync( totalOfExecutions : 1, runInParallel : false, handler : async exection => { #region Arrange var resultA = false; var resultB = false; var addressValueObjectA = new AddressValueObject( complement: null ); var addressValueObjectB = new AddressValueObject( complement: "Complement XPTO" ); var specification = ServiceProvider.GetService <IAddressValueObjectMustHaveComplementWithValidLengthSpecifcation>(); #endregion #region Act resultA = await specification.IsSatisfiedBy(addressValueObjectA).ConfigureAwait(false); resultB = await specification.IsSatisfiedBy(addressValueObjectB).ConfigureAwait(false); #endregion #region Assert return(resultA && resultB); #endregion } ).ConfigureAwait(false); }
public async Task AddressValueObjectMustHaveNumberSpecification_IsSatisfiedBy_Success() { _ = await RunWithTelemetryAsync( totalOfExecutions : 1, runInParallel : false, handler : async exection => { #region Arrange var result = false; var addressValueObject = new AddressValueObject( number: "123456" ); var specification = ServiceProvider.GetService <IAddressValueObjectMustHaveNumberSpecification>(); #endregion #region Act result = await specification.IsSatisfiedBy(addressValueObject).ConfigureAwait(false); #endregion #region Assert return(result); #endregion } ).ConfigureAwait(false); }
public void EqualsOperatorShouldNotBeTrueIfComparedWithNull() { AddressValueObject valueObject1 = new AddressValueObject("Georgia", "Tbilisi", "Street Ave", "13"); AddressValueObject valueObject2 = null; valueObject1.Equals(valueObject2).Should().BeFalse(); }
public async Task AddressValueObjectMustHaveComplementWithValidLengthSpecifcation_IsSatisfiedBy_Fail() { _ = await RunWithTelemetryAsync( totalOfExecutions : 1, runInParallel : false, handler : async exection => { #region Arrange var result = false; var addressValueObject = new AddressValueObject( complement: new string('A', 256) ); var specification = ServiceProvider.GetService <IAddressValueObjectMustHaveComplementWithValidLengthSpecifcation>(); #endregion #region Act result = await specification.IsSatisfiedBy(addressValueObject).ConfigureAwait(false); #endregion #region Assert return(!result); #endregion } ).ConfigureAwait(false); }
public void EqualsShouldNotBeTrueIfValueObjectsDoNotMatchByValue() { AddressValueObject valueObject1 = new AddressValueObject("Georgia", "Tbilisi", "Street Ave", "13"); AddressValueObject valueObject2 = new AddressValueObject("Georgia", "Tbilisi", "Street Ave", "134"); valueObject1.Equals(valueObject2).Should().BeFalse(); }
public void EqualsShouldBeTrueIfValueObjectsAreTheSameReference() { AddressValueObject valueObject1 = new AddressValueObject("Georgia", "Tbilisi", "Street Ave", "13"); AddressValueObject sameReference = valueObject1; valueObject1.Equals(sameReference).Should().BeTrue(); }
public void EqualityOperatorShouldBeFalseIfValueObjectsDoNotMatchByValue() { AddressValueObject valueObject1 = new AddressValueObject("Georgia", "Tbilisi", "Street Ave", "13"); AddressValueObject valueObject2 = new AddressValueObject("Georgia", "Tbilisi", "Street Ave", "134"); (valueObject1 == valueObject2).Should().BeFalse(); }
public Client( AddressValueObject address, DateTime?dateOfBirth, string email, string fax, int id, bool isArchived, bool isDeleted, bool isProspect, string name, string phone, AddressValueObject postalAddress, string website) { this.Address = address; this.DateOfBirth = dateOfBirth; this.Email = email; this.Fax = fax; this.Id = id; this.IsArchived = isArchived; this.IsDeleted = isDeleted; this.IsProspect = isProspect; this.Name = name; this.Phone = phone; this.PostalAddress = postalAddress; this.Website = website; }
public Task ChangeAddress(AddressValueObject address) { Address = new AddressValueObject(address); return(Task.CompletedTask); ; }
public void ShouldBeSameForTheSameInstance() { AddressValueObject valueObject1 = new AddressValueObject("Georgia", "Tbilisi", "Street Ave", "13"); int hashCode1 = valueObject1.GetHashCode(); int hashCode2 = valueObject1.GetHashCode(); hashCode1.Should().Be(hashCode2); }
public void ShouldNotBeSameForTheDifferentInstancesWithDifferentValues() { AddressValueObject valueObject1 = new AddressValueObject("Georgia", "Tbilisi", "Street Ave", "13"); AddressValueObject valueObject2 = new AddressValueObject("Georgia", "Kutaisi", "Street Ave", "134"); int hashCode1 = valueObject1.GetHashCode(); int hashCode2 = valueObject2.GetHashCode(); hashCode1.Should().NotBe(hashCode2); }
private static Address ConstructAddress(AddressValueObject addressVO, ResolutionContext context) { return(new Address( addressVO.Lat, addressVO.Lng, addressVO.Name, addressVO.WithPets, addressVO.PetPhoto )); }
private async Task Handle(CreateBillCommand command) { await HandleCommand(command, async x => { var recipientAddress = new AddressValueObject(command.City, command.Street, command.Number); var bill = await _billFactory.Create(command.Id, command.Metadata.TenantId, command.Name, (BillType)command.Type, command.RecipientName, recipientAddress); await _billRepository.SaveAsync(bill); }); }
public AddressValueObject(AddressValueObject address) { Country = address.Country; Voivodeship = address.Voivodeship; County = address.County; Community = address.Community; City = address.City; District = address.District; Street = address.Street; Number = address.Number; }
public override void Define() { AddressValueObject address = null; When().Match(() => address, l => !string.IsNullOrEmpty(l.Line1) || !string.IsNullOrEmpty(l.Line2) || !string.IsNullOrEmpty(l.City) || !string.IsNullOrEmpty(l.State) || !string.IsNullOrEmpty(l.ZipCode)); Then().Do(c => address.Validate()); }
public void ImportOrderShipping( TenantInfoValueObject tenant, SystemUser executionSystemUser, Order order, AddressValueObject address, string observation) { SetNewId(); SetAddress(address); SetObservation(observation); SetOrder(order); SetTenant(tenant); SetCreationInfo(executionSystemUser.Username); }
public Recipient(Guid id, string name, AddressValueObject address) : base(id) { Name = name; Address = new AddressValueObject(address); }
public async Task GetAllUsersAsyncShouldReturnsList() { // Setup var addressVO = new AddressValueObject { Name = "The Address", Lat = 0, Lng = 0, WithPets = true, PetPhoto = "" }; var user = new UserEntity { Id = "123", Name = "John Smith", Address = addressVO }; var _list = new List <UserEntity> { user }; //Mock MoveNextAsync Mock <IAsyncCursor <UserEntity> > mockCursor = new Mock <IAsyncCursor <UserEntity> >(); mockCursor.Setup(_ => _.Current).Returns(_list); mockCursor .SetupSequence(_ => _.MoveNext(It.IsAny <CancellationToken>())) .Returns(true) .Returns(false); mockCursor .SetupSequence(_ => _.MoveNextAsync(It.IsAny <CancellationToken>())) .Returns(Task.FromResult(true)) .Returns(Task.FromResult(false)); //Mock FindSync _mockCollection.Setup(op => op.FindAsync(It.IsAny <FilterDefinition <UserEntity> >(), It.IsAny <FindOptions <UserEntity, UserEntity> >(), It.IsAny <CancellationToken>())).ReturnsAsync(mockCursor.Object); _mockDB.Setup(c => c.GetCollection <UserEntity>(MongoConstants.UsersCollectionName, null)).Returns(_mockCollection.Object); _mockClient.Setup(c => c.GetDatabase(MongoConstants.DatabaseName, null)).Returns(_mockDB.Object); var repo = new UserRepository(_mockClient.Object, _mapper); var expected = new List <User> { new User("123", "John Smith", new Address(0, 0, "The Address", true, "")) }; // Act var actual = await repo.GetAllUsersAsync(); // Assert Assert.Collection(actual, item => { Assert.Equal("123", item.Id); Assert.Equal("John Smith", item.Name); Assert.Equal("The Address", item.Address.Name); } ); }
private void SetAddress(AddressValueObject address) { Address = address; }
public Task <Bill> Create(Guid id, Guid?tenantId, string name, BillType type, string recipientName, AddressValueObject recipientAddress) { var bill = new Bill(id, tenantId, name, type, null, null, new Recipient(Guid.NewGuid(), recipientName, recipientAddress), new List <Payment>()); return(Task.FromResult(bill)); }
protected bool Equals(AddressValueObject other) { return(string.Equals(Country, other.Country) && string.Equals(Voivodeship, other.Voivodeship) && string.Equals(County, other.County) && string.Equals(Community, other.Community) && string.Equals(City, other.City) && string.Equals(District, other.District) && string.Equals(Street, other.Street) && string.Equals(Number, other.Number)); }