public void BuildPath_Adds_Fields_Parameter() { var fields = new[] { "field1", "field2(f1,f2,f3)" }; var path = PathBuilder.BuildPath("some/path", new RequestOptions(fields)); path.Should().Be("some/path/?fields=field1,field2(f1,f2,f3)"); }
public void SetUp() { var path = new[] { "path1, path2 " }; this.ContentRepository.Stub(r => r.FindContent(path)).Return(null); this.result = this.RenderingService.GetPage(path, null, null, false); }
public void Saml2Response_Read_BasicParams() { string response = @"<?xml version=""1.0"" encoding=""UTF-8""?> <saml2p:Response xmlns:saml2p=""urn:oasis:names:tc:SAML:2.0:protocol"" ID = ""Saml2Response_Read_BasicParams"" Version=""2.0"" IssueInstant=""2013-01-01T00:00:00Z"" InResponseTo = ""InResponseToId"" Destination=""http://destination.example.com""> <saml2p:Status> <saml2p:StatusCode Value=""urn:oasis:names:tc:SAML:2.0:status:Requester"" /> </saml2p:Status> </saml2p:Response>"; var expected = new { Id = new Saml2Id("Saml2Response_Read_BasicParams"), IssueInstant = new DateTime(2013, 01, 01, 0, 0, 0, DateTimeKind.Utc), Status = Saml2StatusCode.Requester, Issuer = new EntityId(null), DestinationUrl = new Uri("http://destination.example.com"), MessageName = "SAMLResponse", InResponseTo = new Saml2Id("InResponseToId"), RequestState = (StoredRequestState)null, }; Saml2Response.Read(response).ShouldBeEquivalentTo(expected, opt => opt.Excluding(s => s.XmlDocument)); }
public void InputProductImagePack_return_你沒有上傳任何檔案Test() { // arrange var mockFile = Substitute.For<HttpPostedFileBase>(); mockFile.ContentLength.Returns(0); var mockProductService = Substitute.For<IProductService>(); var mockBlobService = Substitute.For<IBlobService>(); var mockZipService = Substitute.For<IZipService>(); var uploadController = new UploadController(mockProductService, mockBlobService, mockZipService); var expected = new { errorMessage = "你沒有上傳任何檔案" }; // act var result = uploadController.InputProductImagePack(mockFile) as JsonResult; // assert result.Should().NotBeNull(); result.Data.ShouldBeEquivalentTo(expected); }
public void Can_read() { var expected = new { One = new { Name = AutoFixture.Create<string>(), User = AutoFixture.Create<string>(), }, Two = new { Name = AutoFixture.Create<string>(), User = AutoFixture.Create<string>(), } }; var json = $"{{\"reactions\":{{\"{expected.One.Name}\":{{\"usernames\":[\"{expected.One.User}\"]}}, \"{expected.Two.Name}\":{{\"usernames\":[\"{expected.Two.User}\"]}} }}}}"; // Act var obj = JsonConvert.DeserializeObject<RocketReactionConverterModel>(json); // Assert obj.Reactions.Count.Should().Be(2); obj.Reactions[0].Name.Should().Be(expected.One.Name); obj.Reactions[0].Usernames[0].Should().Be(expected.One.User); obj.Reactions[1].Name.Should().Be(expected.Two.Name); obj.Reactions[1].Usernames[0].Should().Be(expected.Two.User); }
public void IsTranscodingRunning_WhenTranscodingIsRunning_ShouldReturnCorrectValue( [Frozen]TestSchedulers schedulers, [Frozen]Mock<ITranscodingNotifications> notifications, Fixture fixture) { //arrange var notificationsObservable = schedulers.CreateHotObservable( OnNext(202, false), OnNext(203, false), OnNext(204, true), OnNext(205, false) ); notifications.Setup(n => n.ObserveIsTranscodingRunning()).Returns(notificationsObservable); var sut = fixture.Create<ConfigurationPageViewModel>(); //act var actual = schedulers.Start(() => sut.IsTranscodingRunning); //assert var expected = new[] { OnNext(200, false), OnNext(204, true), OnNext(205, false) }; actual.Messages.ShouldAllBeEquivalentTo(expected); }
public void MoreLikeThis_Deserializes() { var stopWords = new [] {"no", "stopwords"}; var q = this.SerializeThenDeserialize( f=>f.MoreLikeThis, f=>f.MoreLikeThis(mlt=>mlt .Analyzer("my-analyzer") .Boost(2.1) .BoostTerms(1.2) .LikeText("likeme") .MaxDocumentFrequency(2) .MaxQueryTerms(3) .MaxWordLength(10) .MinDocumentFrequency(2) .MinTermFrequency(2) .MinWordLength(2) .OnFields(p=>p.Name, p=>p.MyGeoShape) .StopWords(stopWords) .TermMatchPercentage(0.9) ) ); q.Analyzer.Should().Be("my-analyzer"); q.Boost.Should().Be(2.1); q.BoostTerms.Should().Be(1.2); q.LikeText.Should().Be("likeme"); q.MaxDocumentFrequency.Should().Be(2); q.MaxQueryTerms.Should().Be(3); q.MaxWordLength.Should().Be(10); q.MinDocumentFrequency.Should().Be(2); q.MinTermFrequency.Should().Be(2); q.MinWordLength.Should().Be(2); q.Fields.Should().BeEquivalentTo(new [] { "name", "myGeoShape"}); q.StopWords.Should().BeEquivalentTo(stopWords); q.TermMatchPercentage.Should().Be(0.9); }
public void CanUseSetParametersWithStartStepEnd() { var args = new[] { "-channelName channel", "-suiteLib suiteAssembly", "-suiteType testerType", "-subjectAssm subjectAssembly", "-subjecType testedObjectType", "-testMethod testMethodName", "-start 0", "-step 1", "-end 10" }; var parameters = new StartParameters(args); parameters.ChannelName.Should().Be("channel"); parameters.SuiteAssembly.Should().Be("suiteAssembly"); parameters.SuiteType.Should().Be("testerType"); parameters.SubjectAssembly.Should().Be("subjectAssembly"); parameters.SubjectType.Should().Be("testedObjectType"); parameters.TestMethod.Should().Be("testMethodName"); parameters.Start.Should().Be("0"); parameters.Step.Should().Be("1"); parameters.End.Should().Be("10"); }
public void PostIdTokenValidation_MissingToken_ReturnsBadRequest() { var form = new { }; var resp = PostForm(TestUrl, form); resp.StatusCode.Should().Be(HttpStatusCode.BadRequest); }
public void GeoShapeMultiLineString_Deserializes(string cacheName, string cacheKey, bool cache) { var coordinates = new[] { new[] { new[] { 102.0, 2.0 }, new[] { 103.0, 2.0 }, new[] { 103.0, 3.0 }, new[] { 102.0, 3.0 } }, new[] { new[] { 100.0, 0.0 }, new[] { 101.0, 0.0 }, new[] { 101.0, 1.0 }, new[] { 100.0, 1.0 } }, new[] { new[] { 100.2, 0.2 }, new[] { 100.8, 0.2 }, new[] { 100.8, 0.8 }, new[] { 100.2, 0.8 } } }; var geoBaseShapeFilter = this.SerializeThenDeserialize(cacheName, cacheKey, cache, f => f.GeoShape, f => f.GeoShapeMultiLineString(p => p.Origin, d => d .Coordinates(coordinates) ) ); var filter = geoBaseShapeFilter as IGeoShapeMultiLineStringFilter; filter.Should().NotBeNull(); filter.Field.Should().Be("origin"); filter.Should().NotBeNull(); filter.Shape.Should().NotBeNull(); filter.Shape.Type.Should().Be("multilinestring"); filter.Shape.Coordinates.SelectMany(c => c.SelectMany(cc => cc)).Should() .BeEquivalentTo(coordinates.SelectMany(c => c.SelectMany(cc => cc))); }
public void DelimitedString_Split_EscapeCharaters() { var actual = DelimitedString.Split("a/,b//c,/,,//,"); var expected = new[] { "a,b/c", ",", "/", "" }; actual.Should().BeEquivalentTo(expected); }
public void OrderBy_MultipleOrderBys() { // Assemble var values = new[] { new { A = 1, B = 1, C = 1 }, new { A = 2, B = 1, C = 2 }, new { A = 2, B = 2, C = 3 }, new { A = 3, B = 1, C = 4 }, new { A = 3, B = 0, C = 5 }, // Highest A, lowest B new { A = 3, B = 2, C = 6 }, }; // Act var highestALowestB = from v in values orderby v.C ascending orderby v.B ascending orderby v.A descending select v; // Assert var first = highestALowestB.First(); Assert.AreEqual(3, first.A); Assert.AreEqual(0, first.B); Assert.AreEqual(5, first.C); }
public void SetUp() { var templatePath = new[] { "test", "path" }; this.template = new Template(templatePath); var newComponent = new Atom("component1", null); this.template.Insert(0, newComponent); }
public void MetricTags_CanCreateFromStringArray() { MetricTags tags = new[] { "tag1", "tag2" }; tags.Tags.Should().Equal(new[] { "tag1", "tag2" }); tags = new MetricTags(new[] { "tag1", "tag2" }); tags.Tags.Should().Equal(new[] { "tag1", "tag2" }); }
public void DelimitedString_Split_EndsWithEscapedDelimiter() { var actual = DelimitedString.Split("a/,"); var expected = new[] { "a," }; actual.Should().BeEquivalentTo(expected); }
public void DelimitedString_Split_EmptyStrings() { var actual = DelimitedString.Split(",aa,,bb,"); var expected = new[] { "", "aa", "", "bb", "" }; actual.Should().BeEquivalentTo(expected); }
public void DelimitedString_Split_SimpleWithoutEscaping() { var actual = DelimitedString.Split("aa,bb,cc"); var expected = new[] { "aa", "bb", "cc" }; actual.Should().BeEquivalentTo(expected); }
public void GetIndexName_with_names_should_return_expected_result() { var keys = new[] { "a", "b", "c c" }; var expectedResult = "a_1_b_1_c_c_1"; var result = IndexNameHelper.GetIndexName(keys); result.Should().Be(expectedResult); }
public void TestEnumerableToString() { const string separator = ", "; var enumerable = new[] { 0, 1, 2, 3, 4 }; const string whatEnumerableAsStringShouldBe = "0, 1, 2, 3, 4"; var enumerableAsString = enumerable.ToString(separator); enumerableAsString.Should().NotBeNull(); enumerableAsString.Should().Be(whatEnumerableAsStringShouldBe); }
public void AreEqual_ShouldReturnFalse() { var source = new { Name = "Chris" }; var target = new { Name = "John" }; var result = DynamicProperties.AreEqual(source, target); result.Should().BeFalse(); }
public void RequiredScopeIsNotGranted_AuthorizationShouldBeDenied( string grantedScopePattern, string requiredScopePattern ) { var grantedScopes = new[] { Scope.Parse( grantedScopePattern ) }; bool isAuthorized = ScopeAuthorizer.IsAuthorized( grantedScopes, Scope.Parse( requiredScopePattern ) ); isAuthorized.Should().BeFalse(); }
public void CanCreateInstance() { var uriBuilder = new BlobstoreUriBuilder("http://localhost:8080"); var fileList = new[] { "Foo.pdf", "Bar.pdf" }; var testee = new BlobstoreFileList(uriBuilder, "110024d6-de1b-4bd9-88e5-343f55c2e0e9", fileList); testee.Files.Should().Contain(f => f.Identifier == "110024d6-de1b-4bd9-88e5-343f55c2e0e9" && f.FileName == "Foo.pdf"); testee.Files.Should().Contain(f => f.Identifier == "110024d6-de1b-4bd9-88e5-343f55c2e0e9" && f.FileName == "Bar.pdf"); }
public void when_requested_size_is_3_then_return_a_3x3_table_with_the_products_calculated() { var expectedTable = new[,] { {1 , 2, 3}, {2 , 4, 6}, {3 , 6, 9} }; PrimeTable.WithSizeOf(3).ToGridArray().Should().BeEquivalentTo(expectedTable); }
public void BuildPath_Adds_Query_Fields_Cursor_And_Limit_Parameters() { var query = "search query"; var fields = new[] {"field1", "field2(f1,f2,f3)"}; var cursor = "abcdefg"; var limit = 10; var path = PathBuilder.BuildPath("some/path", new RequestOptions(query, fields, cursor, limit)); path.Should().Be("some/path/?query=search query&fields=field1,field2(f1,f2,f3)&cursor=abcdefg&limit=10"); }
public async Task Anonymous_User_Should_Be_Allowed() { var principal = Principal.Anonymous; var allowedScopes = new[] { "scope1", "scope2" }; var client = CreateClient(principal, allowedScopes); var response = await client.GetAsync("/"); response.StatusCode.Should().Be(HttpStatusCode.OK); }
public void TestObjectToJson() { var myObj = new { FirstName = "John", LastName = "Doe" }; var json = myObj.ToJson(); json.Should().Be(JsonConvert.SerializeObject(myObj)); }
public void TestObjectToPrettyJson() { var myObj = new { FirstName = "John", LastName = "Doe" }; var json = myObj.ToPrettyJson(); json.Should().Be(JsonConvert.SerializeObject(myObj, Formatting.Indented)); }
public async Task returns_all_elements() { // Given var src = new [] {1,2,3}.ToObservable().CacheLast(); // When var result = await src.ToArray(); // Then result.Should().Equal(1, 2, 3); }
public async Task Authenticated_User_Missing_Scopes_Should_Be_Forbidden() { var principal = Principal.Create("custom", new Claim("sub", "123")); var allowedScopes = new[] { "scope1", "scope2" }; var client = CreateClient(principal, allowedScopes); var response = await client.GetAsync("/"); response.StatusCode.Should().Be(HttpStatusCode.Forbidden); }
public void InputProductImagePack_return_圖片數量不可超過500張() { // arrange var mockFile = Substitute.For<HttpPostedFileBase>(); mockFile.ContentLength.Returns(10); mockFile.FileName.Returns("fileName"); var stream = Substitute.For<Stream>(); mockFile.InputStream.Returns(stream); var mockProductService = Substitute.For<IProductService>(); var mockBlobService = Substitute.For<IBlobService>(); var mockZipService = Substitute.For<IZipService>(); var mockZip = Substitute.For<ZipFile>(); mockZipService.Read(Arg.Any<Stream>()).Returns(mockZip); mockZipService.EntriesCount(Arg.Any<ZipFile>()).Returns(501); var uploadController = new UploadController(mockProductService, mockBlobService, mockZipService); var expected = new { errorMessage = "圖片數量不可超過500張" }; // act var result = uploadController.InputProductImagePack(mockFile) as JsonResult; // assert result.Should().NotBeNull(); result.Data.ShouldBeEquivalentTo(expected); }