public void Exception_Is_Rethrown() { Assert.That(() => ClassInTest.RebuildFromBase64(new Base64Request { Base64 = "dGVzdA==" }), Throws.Exception.EqualTo(_dummyException)); }
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)); FileProtectorMock.Setup(s => s.GetProtectedFile( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(_expectedProtectResponse = new FileProtectResponse { Outcome = EngineOutcome.Error, ProtectedFile = null, ErrorMessage = "banana has been removed because monkey content is set to disallowed" }); _result = ClassInTest.RebuildFromBase64(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)); FileProtectorMock.Setup(s => s.GetProtectedFile( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(new FileProtectResponse { Outcome = EngineOutcome.Success, ProtectedFile = ExpectedDecoded }); _result = ClassInTest.RebuildFromBase64(new Base64Request { Base64 = "dGVzdA==" }); }
public void OnetimeSetup() { CommonSetup(); ClassInTest.ModelState.AddModelError("SomeError", "SomeMessage"); _result = ClassInTest.RebuildFromBase64(null); }
public void Bad_Request_Is_Returned(string base64) { _result = ClassInTest.RebuildFromBase64(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.RebuildFromBase64(new Base64Request { Base64 = base64 }); GlasswallVersionServiceMock.VerifyNoOtherCalls(); FileTypeDetectorMock.VerifyNoOtherCalls(); FileProtectorMock.VerifyNoOtherCalls(); }
public void Bad_Request_Contains_Message(string base64) { _result = ClassInTest.RebuildFromBase64(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.RebuildFromBase64(new Base64Request { Base64 = "dGVzdA==" }); }
public void Metrics_Are_Recorded(string base64) { ClassInTest.RebuildFromBase64(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(); }