コード例 #1
0
        public void CanSendMessageToQueueOnSuccessfulContactInsert()
        {
            Contact contact = Contact.Create(new Name("Julie", "Lerman"), "Friend Referral");
              var repo = new ContactAggregateRepository();
              repo.PersistNewContact(contact);

              Assert.Inconclusive("Check status of RabbitMQ Manager for this message");
        }
コード例 #2
0
        public void WillNotSendMessageToQueueOnSuccessfulContactAddressUpdate()
        {
            Contact contact = Contact.Create(new Name("George", "Jetson"), "Spacely Sprockets Referral");
              var repo = new ContactAggregateRepository();
              repo.PersistNewContact(contact);
              contact.CreateNewAddress("123 SkyPad Apartments", "", "Orbit City", "Orbit", "n/a", "");
              repo.PersistChangeToContact(contact);

              Assert.Inconclusive(@"Check status of RabbitMQ Manager for a create message,
                          but no update message because name was not changed");
        }
コード例 #3
0
        public void CanSendMessageToQueueOnSuccessfulContactNameUpdate()
        {
            Contact contact = Contact.Create(new Name("Spamson", "Lerman"), "Friend Referral");
              var repo = new ContactAggregateRepository();
              repo.PersistNewContact(contact);
              contact.FixName(new Name("Sampson", "Lerman"));

              repo.PersistChangeToContact(contact);

              Assert.Inconclusive("Check status of RabbitMQ Manager for a create message and an update message");
        }
コード例 #4
0
        // POST api/<controller>
        //public Guid Post(HttpRequestMessage request) {
        //  var str = Request.Content.ReadAsStringAsync().Result;
        //  var c = Newtonsoft.Json.JsonConvert.DeserializeObject<ContactWithAddressDto>(str);
        //  return Guid.Empty;
        //}
        public Guid Post(HttpRequestMessage request)
        {
            var repo = new ContactAggregateRepository();
              string str = Request.Content.ReadAsStringAsync().Result;
              var c = JsonConvert.DeserializeObject<ContactWithAddressDto>(str);

              Contact contact = Contact.Create(new Name(c.FirstName, c.LastName), "Sales");
              var cA = c.PrimaryAddress;
              contact.CreateNewAddress(cA.Street1, cA.Street2, cA.City, cA.Region, cA.Country, cA.PostalCode);
              if (repo.PersistNewContact(contact)) {
            return contact.Id;
              }
              return Guid.Empty;
        }
コード例 #5
0
        public void WillNotSendMessageToQueueOnFailedContactUpdate()
        {
            Contact contact = Contact.Create(new Name("Unpersisted", "Contact"), "Friend Referral");
              var repo = new ContactAggregateRepository();
              contact.FixName(new Name("WasNeverPersisted", "Contact"));
              //note, did not persist the new Contact, so reupdate will fail
              try {
            repo.PersistChangeToContact(contact);
              }
              catch (DbUpdateConcurrencyException) {
            //swallow this exception so we can be sure that when it happens, the message won't get pushed into the queue
              }

              Assert.Inconclusive("There should be no messages in the queue at all");
        }