public string Post([FromBody] AssociationRegister associationRegister) { var associationId = Guid.NewGuid().ToString(); var addressId = associationRegister.AddressId ?? Guid.NewGuid().ToString(); _commandProcessor.ProcessCommand(new CreateAssociationCommand(associationId) { Name = associationRegister.Name }); _commandProcessor.ProcessCommand(new RegisterUserToAssociationCommand(associationId) { UserId = associationRegister.UserId }); _commandProcessor.ProcessCommand(new AddAddressToAssociationCommand(associationId) { Id = addressId, StreetAddress = associationRegister.StreetAddress, No = associationRegister.No, Floor = associationRegister.Floor, Door = associationRegister.Door, City = associationRegister.City, Zip = associationRegister.Zip, Country = "+45" }); _commandProcessor.ProcessCommand(new AttachUserToAddressCommand(associationId) { UserId = associationRegister.UserId, AddressId = addressId }); return(associationId); }
public void Post_AddressIdIsUnique() { var postModel = new AssociationRegister { Name = "name", StreetAddress = "address", No = "no", Floor = "floor", Door = "door", City = "city", Zip = "zip", UserId = "user123" }; var associationId = _controller.Post(postModel); _commandProcessorMock.Received().ProcessCommand(Arg.Is <AddAddressToAssociationCommand>(ac => ac.Id.Length == 36)); }
public void Post_CreatedCorreclyAndAddressIdAssigned() { var postModel = new AssociationRegister { Name = "name", AddressId = "address123", StreetAddress = "address", No = "no", Floor = "floor", Door = "door", City = "city", Zip = "zip", UserId = "user123" }; var associationId = _controller.Post(postModel); _commandProcessorMock.Received().ProcessCommand(Arg.Any <CreateAssociationCommand>()); _commandProcessorMock.Received().ProcessCommand(Arg.Any <RegisterUserToAssociationCommand>()); _commandProcessorMock.Received().ProcessCommand(Arg.Is <AddAddressToAssociationCommand>(ac => ac.Id == postModel.AddressId)); _commandProcessorMock.Received().ProcessCommand(Arg.Any <AttachUserToAddressCommand>()); }