public void Exception_Is_Rethrown() { Assert.That(() => ClassInTest.AnalyseFromBase64(new Base64Request { Base64 = "dGVzdA==" }), Throws.Exception.EqualTo(_dummyException)); }
public void OnetimeSetup() { CommonSetup(); ClassInTest.ModelState.AddModelError("SomeError", "SomeMessage"); _result = ClassInTest.AnalyseFromBase64(null); }
public void Bad_Request_Is_Returned(string base64) { _result = ClassInTest.AnalyseFromBase64(new Base64Request { Base64 = base64 }); Assert.That(_result, Is.Not.Null); Assert.That(_result, Is.TypeOf <BadRequestObjectResult>()); }
public void No_Engine_Actions_Are_Performed(string base64) { ClassInTest.AnalyseFromBase64(new Base64Request { Base64 = base64 }); GlasswallVersionServiceMock.VerifyNoOtherCalls(); FileTypeDetectorMock.VerifyNoOtherCalls(); FileAnalyserMock.VerifyNoOtherCalls(); }
public void Bad_Request_Contains_Message(string base64) { _result = ClassInTest.AnalyseFromBase64(new Base64Request { Base64 = base64 }); var result = _result as BadRequestObjectResult; Assert.That(result, Is.Not.Null); Assert.That(result.Value, Is.InstanceOf <string>()); Assert.That(result.Value, Is.EqualTo("Input file could not be decoded from base64.")); }
public void OnetimeSetup() { CommonSetup(); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(new FileTypeDetectionResponse(FileType.Unknown)); _result = ClassInTest.AnalyseFromBase64(new Base64Request { Base64 = "dGVzdA==" }); }
public void OnetimeSetup() { CommonSetup(); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(_expectedType = new FileTypeDetectionResponse(FileType.Bmp)); FileAnalyserMock.Setup(s => s.GetReport( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(DummyXml); _result = ClassInTest.AnalyseFromBase64(new Base64Request { Base64 = "dGVzdA==" }); }
public void Metrics_Are_Recorded(string base64) { ClassInTest.AnalyseFromBase64(new Base64Request { Base64 = base64 }); MetricServiceMock.Verify(s => s.Record( It.Is <string>(x => x == Metric.Base64DecodeTime), It.Is <TimeSpan>(x => x > TimeSpan.Zero)), Times.Once); MetricServiceMock.Verify(s => s.Record( It.Is <string>(x => x == Metric.FileSize), It.Is <int>(x => x == 0)), Times.Once); MetricServiceMock.VerifyNoOtherCalls(); }