public void AssertExceptionThrownWhenClassIsMissingFromSnailMailAttribute()
 {
     XElement element = XElement.Parse("<SnailMail>19 Baker St, London, W12 4TF</SnailMail>");
     var mockSnailMail = new Mock<ILegacySnailMailCreator>();
     IElementToPartyTranslator elementToSnailMail = new ElementToSnailMail(mockSnailMail.Object);
     var ex = Assert.Throws<Exception>(() => elementToSnailMail.Translate(element));
     Assert.Equal("Class attribute of SnailMail element was null", ex.Message);
 }
 public void TestSnailMailIsParsedProperly()
 {
     XElement element = XElement.Parse("<SnailMail class=\"FirstClass\">19 Baker St, London, W12 4TF</SnailMail>");
     var mockSnailMail = new Mock<ILegacySnailMailCreator>();
     IElementToPartyTranslator elementToSnailMail = new ElementToSnailMail(mockSnailMail.Object);
     elementToSnailMail.Translate(element);
     var ele = elementToSnailMail as ElementToSnailMail;
     Assert.Equal("FirstClass", ele.PostageClass.ToString());
     Assert.Equal("19 Baker St, London, W12 4TF", ele.Address);
 }
 public void TestParsedSnailMailCallCanCallLegacyStub()
 {
     //I want to create an element that signifies a SnailMail delivery, put the right details in and ensure it will call the underlying legacy class correctly
     XElement element = XElement.Parse("<SnailMail class=\"FirstClass\">19 Baker St, London, W12 4TF</SnailMail>");
     var mockSnailMail = new Mock<ILegacySnailMailCreator>();
     var mockIContactable = new Mock<IContactable>();
     mockSnailMail.Setup(f => f.CreateContactable("19 Baker St, London, W12 4TF", SnailMail.Stamp.FirstClass)).Returns(mockIContactable.Object);
     IElementToPartyTranslator elementToSnailMail = new ElementToSnailMail(mockSnailMail.Object);
     IContactable connectableDevice = elementToSnailMail.Translate(element);
     connectableDevice.Contact("Hello - Party time");
     mockSnailMail.Verify(f => f.CreateContactable("19 Baker St, London, W12 4TF", SnailMail.Stamp.FirstClass), Times.AtMostOnce());
     mockIContactable.Verify(c => c.Contact("Hello - Party time"), Times.AtMostOnce());
 }