public void FormatConvertorFacade_Call_All_Required_Methods_Test() { string expectedInputXmlContent = "cokoli"; FormatConvertorFacade formatConvertorFacade = new FormatConvertorFacade(deserializerFromXmlMock.Object, convertorFactoryMock.Object); // objekt ke konverzi DocToConvert docToConvert = new DocToConvert { TargetFormat = TargetFormatType.Json, XmlContent = expectedInputXmlContent, }; ConvertedResult convertedResult = formatConvertorFacade.GetConvertedResult(docToConvert); // ASSERT // že voláme metodu DeserializeFromXml s xml content z dodaného DocToConvert objektu deserializerFromXmlMock.Verify(x => x.DeserializeFromXml(It.Is <string>(s => s.Equals(expectedInputXmlContent))), Times.Once); // CreateObjectConvertor se správným TargetFormat convertorFactoryMock.Verify(x => x.CreateObjectConvertor(docToConvert.TargetFormat), Times.Once); //metoda SerializeObject zavolána s očekávaným objektem this.jsonConvertorMock.Verify(x => x.SerializeObject(It.Is <Notino_Homework_Stryncl.Models.Document>(d => d.Title == expectedDocument.Title && d.Text == expectedDocument.Text)), Times.Once); Assert.Equal(docToConvert.TargetFormat, convertedResult.TargetFormat); Assert.Equal(ExpectedJsonContent, convertedResult.Content); }
public FormatConvertorController(FormatConvertorFacade convertorFacade) { this.convertorFacade = convertorFacade; }