public async Task Version_should_be_compatible()
        {
            // This isn't really a test.
            // It's here for my own record keeping, 
            //  if something breaks I'll know the last good version from
            //  test/git history

            var supportedVersions = new[]
            {
                //"0.22.0",
                //"0.25.0",
                //"0.26.0",
                //"0.27.0",
                //"0.28.0",
                // Broken at 0.29.0
                //"0.29.0",
                //"0.30.0",
                //"0.31.0",
                // Pin messages broken, different return room lookup
                "0.32.0",
                "0.33.0",
                "0.34.0",
                "0.35.0",
            };

            await DefaultAccountLoginAsync();

            // Act
            var results = await RocketChatDriver.GetStatisticsAsync();

            // Assert
            supportedVersions.Should().Contain(results.Result.Version);
        }
		[U] public async Task Urls()
		{
			await POST("/_tasks/_cancel")
				.Fluent(c => c.CancelTasks())
				.Request(c => c.CancelTasks(new CancelTasksRequest()))
				.FluentAsync(c => c.CancelTasksAsync())
				.RequestAsync(c => c.CancelTasksAsync(new CancelTasksRequest()))
				;

			var taskId = "node:4";
			await POST($"/_tasks/node%3A4/_cancel")
				.Fluent(c => c.CancelTasks(t=>t.TaskId(taskId)))
				.Request(c => c.CancelTasks(new CancelTasksRequest(taskId)))
				.FluentAsync(c => c.CancelTasksAsync(t=>t.TaskId(taskId)))
				.RequestAsync(c => c.CancelTasksAsync(new CancelTasksRequest(taskId)))
				;

			var nodes = new []{  "node1", "node2" };
			var actions = new[] { "*reindex" };
			await POST($"/_tasks/_cancel?node_id=node1%2Cnode2&actions=%2Areindex")
				.Fluent(c => c.CancelTasks(t => t.NodeId(nodes).Actions(actions)))
				.Request(c => c.CancelTasks(new CancelTasksRequest { NodeId = nodes, Actions = actions }))
				.FluentAsync(c => c.CancelTasksAsync(t => t.NodeId(nodes).Actions(actions)))
				.RequestAsync(c => c.CancelTasksAsync(new CancelTasksRequest { NodeId = nodes, Actions = actions }))
				;
		}
Exemplo n.º 3
0
        public async Task ChangeSignature_Formatting_Method()
        {
            var markup = @"
class C
{
    void $$Method(int a, 
        int b)
    {
        Method(1,
            2);
    }
}";
            var updatedSignature = new[] { 1, 0 };
            var expectedUpdatedCode = @"
class C
{
    void Method(int b,
        int a)
    {
        Method(2,
            1);
    }
}";
            await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: updatedSignature, expectedUpdatedInvocationDocumentCode: expectedUpdatedCode);
        }
Exemplo n.º 4
0
        public async Task ChangeSignature_Formatting_KeepCountsPerLine()
        {
            var markup = @"
class C
{
    void $$Method(int a, int b, int c,
        int d, int e,
        int f)
    {
        Method(1,
            2, 3,
            4, 5, 6);
    }
}";
            var updatedSignature = new[] { 5, 4, 3, 2, 1, 0 };
            var expectedUpdatedCode = @"
class C
{
    void Method(int f, int e, int d,
        int c, int b,
        int a)
    {
        Method(6,
            5, 4,
            3, 2, 1);
    }
}";
            await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: updatedSignature, expectedUpdatedInvocationDocumentCode: expectedUpdatedCode);
        }
Exemplo n.º 5
0
        public async Task ChangeSignature_Formatting_Constructor()
        {
            var markup = @"
class SomeClass
{
    $$SomeClass(int a,
        int b)
    {
        new SomeClass(1,
            2);
    }
}";
            var updatedSignature = new[] { 1, 0 };
            var expectedUpdatedCode = @"
class SomeClass
{
    SomeClass(int b,
        int a)
    {
        new SomeClass(2,
            1);
    }
}";
            await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: updatedSignature, expectedUpdatedInvocationDocumentCode: expectedUpdatedCode);
        }
        public async Task ReorderParameters_Cascade_ToImplementingMethod()
        {
            var markup = @"
interface I
{
    $$void M(int x, string y);
}

class C : I
{
    public void M(int x, string y)
    { }
}";
            var permutation = new[] { 1, 0 };
            var updatedCode = @"
interface I
{
    void M(string y, int x);
}

class C : I
{
    public void M(string y, int x)
    { }
}";

            await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: permutation, expectedUpdatedInvocationDocumentCode: updatedCode);
        }
        public async Task FilterAndGroupDocuments()
        {
            // @begin: filter-and-group-documents
            // @code: start
            var collection = _database.GetCollection<BsonDocument>("restaurants");
            var aggregate = collection.Aggregate()
                .Match(new BsonDocument { { "borough", "Queens" }, { "cuisine", "Brazilian" } })
                .Group(new BsonDocument { { "_id", "$address.zipcode" }, { "count", new BsonDocument("$sum", 1) } });
            var results = await aggregate.ToListAsync();
            // @code: end

            // @results: start
            var expectedResults = new[]
            {
                BsonDocument.Parse("{ _id : '11368', count : 1 }"),
                BsonDocument.Parse("{ _id : '11106', count : 3 }"),
                BsonDocument.Parse("{ _id : '11377', count : 1 }"),
                BsonDocument.Parse("{ _id : '11103', count : 1 }"),
                BsonDocument.Parse("{ _id : '11101', count : 2 }")
            };
            results.Should().BeEquivalentTo(expectedResults);
            // @results: end

            // @end: filter-and-group-documents
        }
        public async Task Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata()
        {
            var primaryData1 = new Mock<IResourceObject>(MockBehavior.Strict);
            var primaryData2 = new Mock<IResourceObject>(MockBehavior.Strict);
            var mockResourceObjectFormatter = new Mock<IResourceObjectFormatter>(MockBehavior.Strict);
            mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData1.Object, It.IsAny<JsonWriter>()))
                .Returns((IResourceObject resourceObject, JsonWriter writer) =>
                {
                    writer.WriteValue("Primary data 1");
                    return Task.FromResult(0);
                });
            mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData2.Object, It.IsAny<JsonWriter>()))
                .Returns((IResourceObject resourceObject, JsonWriter writer) =>
                {
                    writer.WriteValue("Primary data 2");
                    return Task.FromResult(0);
                });

            var mockMetadata = new Mock<IMetadata>(MockBehavior.Strict);
            var mockMetadataFormatter = new Mock<IMetadataFormatter>(MockBehavior.Strict);
            mockMetadataFormatter.Setup(m => m.Serialize(mockMetadata.Object, It.IsAny<JsonWriter>()))
                .Returns((IMetadata resourceObject, JsonWriter writer) =>
                {
                    writer.WriteValue("Placeholder metadata object");
                    return Task.FromResult(0);
                });

            var primaryData = new[] { primaryData1.Object, primaryData2.Object };
            IResourceCollectionDocument document = new ResourceCollectionDocument(primaryData, null, mockMetadata.Object);

            var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object);
            await AssertSerializeOutput(formatter, document, "Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata.json");
        }
Exemplo n.º 9
0
        public async void should_retrieve_builds_for_all_available_devices()
        {
            var inputDevice = Substitute.For<IInputDevice>();
            var connection = Substitute.For<ITeamCityConnection>();
            connection.GetBuild(Arg.Any<string>()).ReturnsForAnyArgs("<builds />");

            var outputDevice1 = Substitute.For<IOutputDevice>();
            outputDevice1.IsAvailable.Returns(true);
            var inputs1 = new[] { buildId1, buildId2 };

            var outputDevice2 = Substitute.For<IOutputDevice>();
            outputDevice2.IsAvailable.Returns(false);
            var inputs2 = new[] { buildId3 };

            var monitor = new TeamCityMonitor(inputDevice, d => connection);
            monitor.AddBuilds(outputDevice1, inputs1);
            monitor.AddBuilds(outputDevice2, inputs2);

            await monitor.BeginMonitoring();

            await Task.WhenAll(
                connection.Received().GetBuild(buildId1),
                connection.Received().GetBuild(buildId2),
                connection.DidNotReceive().GetBuild(buildId3));
        }
Exemplo n.º 10
0
 public IndividualRequestResponse UpdateRequest(Request request, Comment comment=null)
 {
     if (comment != null)
         request.Comment = comment;
     var body = new { request };
     
     return GenericPut<IndividualRequestResponse>(string.Format("requests/{0}.json", request.Id.Value), body);
 }
Exemplo n.º 11
0
        public Task<object> Poll(int topicId)
        {
            var model = new
            {
                topicId
            };

            return Request<object>(model);
        }
Exemplo n.º 12
0
		/// <summary>
		/// Creates or updates the reminder on a object. Possible ref_types are: task.
		/// <para>Podio API Reference: https://developers.podio.com/doc/reminders/create-or-update-reminder-3315055 </para>
		/// </summary>
		/// <param name="refType">Type of the reference.</param>
		/// <param name="refId">The reference identifier.</param>
		/// <param name="remindDelta">minutes to remind before the due date of the object</param>
		/// <returns>Task.</returns>
		public Task Update(string refType, int refId, int remindDelta)
		{
			string url = string.Format("/reminder/{0}/{1}", refType, refId);
			dynamic requestData = new
			{
				remind_delta = remindDelta
			};
			return _podio.PutAsync<dynamic>(url, requestData);
		}
Exemplo n.º 13
0
 public Task<JwtCredentials> Post(string key, string secret, string userId)
 {
     var data = new
     {
         key,
         secret
     };
     return CreateCredentials(data);
 }
Exemplo n.º 14
0
        public Task<object> GetUserAliases(long membershipId) 
        {
            var model = new
            {
                membershipId
            };

            return Request<object>(model); 
        }
Exemplo n.º 15
0
        public Task<object> SearchUsers(string search) 
        {
            var model = new
            {
                search
            };

            return Request<object>(model); 
        }
Exemplo n.º 16
0
        public override async Task Initialize() {
            var queries = new[] { new { type = "microphone" }, new { type = "buzzer" } };
            Server.Observe<Microphone, Buzzer>(queries, async (microphone, buzzer) => {
                var alarm = Device.Create<Alarm>(new object[] { microphone, buzzer });
                await Discover(alarm);
            });

            await Task.FromResult(0);
        }
Exemplo n.º 17
0
        public Task<object> GetTagSuggestions(string partialtag)
        {
            var model = new
            {
                partialtag
            };

            return Request<object>(model);
        }
Exemplo n.º 18
0
 public Task<object> GetAccount(long membershipId, MembershipType membershipType) 
 {
     var model = new
     {
         membershipId,
         membershipType
     };
     
     return Request<object>(model); 
 }
Exemplo n.º 19
0
        public Task<object> GetPostAndParentAwaitingApproval(int childPostId, bool? showBanned = null)
        {
            var model = new
            {
                childPostId,
                showBanned
            };

            return Request<object>(model);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 【异步方法】获取设备及用户信息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="ticket">摇周边业务的ticket,可在摇到的URL中得到,ticket生效时间为30分钟,每一次摇都会重新生成新的ticket</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task<GetShakeInfoResult> GetSuiteTokenAsync(string accessToken, string ticket, int timeOut = Config.TIME_OUT)
        {
            var url = string.Format("https://qyapi.weixin.qq.com/cgi-bin/shakearound/getshakeinfo?access_token={0}", accessToken.AsUrlData());

            var data = new
            {
                ticket = ticket
            };

            return await Senparc .Weixin .CommonAPIs .CommonJsonSend.SendAsync<GetShakeInfoResult>(null, url, data, CommonJsonSendType.POST, timeOut);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 删除邮费模板
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="templateId">邮费模板Id</param>
        /// <returns></returns>
        public static WxJsonResult DeleteExpress(string accessToken, int templateId)
        {
            var urlFormat = "https://api.weixin.qq.com/merchant/express/del?access_token={0}";

            var data = new
            {
                template_id = templateId
            };

            return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 删除分组
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="groupId">分组Id</param>
        /// <returns></returns>
        public static WxJsonResult DeleteGroup(string accessToken, int groupId)
        {
            var urlFormat = "https://api.weixin.qq.com/merchant/group/del?access_token={0}";

            var data = new
            {
                group_id = groupId
            };

            return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data);
        }
Exemplo n.º 23
0
        /// <summary>
        /// 删除货架
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="shelfId">货架Id</param>
        /// <returns></returns>
        public static WxJsonResult DeleteShelves(string accessToken, int shelfId)
        {
            var urlFormat = "https://api.weixin.qq.com/merchant/shelf/del?access_token={0}";

            var data = new
            {
                shelf_id = shelfId
            };

            return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 获取指定ID的邮费模板
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="templateId">邮费模板Id</param>
        /// <returns></returns>
        public static GetByIdExpressResult GetByIdExpress(string accessToken, int templateId)
        {
            var urlFormat = "https://api.weixin.qq.com/merchant/express/getbyid?access_token={0}";

            var data = new
            {
                template_id = templateId
            };

            return CommonJsonSend.Send<GetByIdExpressResult>(accessToken, urlFormat, data);
        }
Exemplo n.º 25
0
		private async Task<string> WriteTracer(IDocumentStore store1)
		{
			var targetStore = store1;
			using(var session = targetStore.OpenAsyncSession())
			{
				var tracer = new {};
				await session.StoreAsync(tracer);
				await session.SaveChangesAsync();
				return session.Advanced.GetDocumentId(tracer);
			}
		}
Exemplo n.º 26
0
        /// <summary>
        /// 删除商品              
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="productId">商品的Id</param>
        /// <returns></returns>
        public static WxJsonResult DeleteProduct(string accessToken, string productId)
        {
            var urlFormat = "https://api.weixin.qq.com/merchant/del?access_token={0}";

            var data = new
            {
                product_id = productId
            };

            return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data);
        }
Exemplo n.º 27
0
        public void TestForEachOneElement()
        {
            var ret = new[] {false};

              Parallel.ForEach(new[] {0}, delegate(int index) {
            Assert.IsFalse(ret[index]);
            ret[index] = true;
              });

              Assert.IsTrue(ret[0]);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 获取企业号管理员登录信息
        /// </summary>
        /// <param name="providerAccessToken">服务提供商的accesstoken</param>
        /// <param name="authCode">oauth2.0授权企业号管理员登录产生的code</param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// <returns></returns>
        public static GetLoginInfoResult GetLoginInfo(string providerAccessToken, string authCode, int timeOut = Config.TIME_OUT)
        {
            string url = "https://qyapi.weixin.qq.com/cgi-bin/service/get_login_info?provider_access_token={0}";

            var data = new
            {
                auth_code = authCode
            };

            return CommonJsonSend.Send<GetLoginInfoResult>(providerAccessToken, url, data, CommonJsonSendType.POST,
                                                           timeOut);
        }
Exemplo n.º 29
0
        /// <summary>
        /// 获取第三方平台access_token
        /// </summary>
        /// <param name="componentAppId">第三方平台appid</param>
        /// <param name="componentAppSecret">第三方平台appsecret</param>
        /// <param name="componentVerifyTicket">微信后台推送的ticket,此ticket会定时推送,具体请见本页末尾的推送说明</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static ComponentAccessTokenResult GetComponentAccessToken(string componentAppId, string componentAppSecret, string componentVerifyTicket, int timeOut = Config.TIME_OUT)
        {
            var url = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";

            var data = new
            {
                component_appid = componentAppId,
                component_appsecret = componentAppSecret,
                component_verify_ticket = componentVerifyTicket
            };

            return CommonJsonSend.Send<ComponentAccessTokenResult>(null, url, data, CommonJsonSendType.POST, timeOut);
        }
Exemplo n.º 30
0
        public void TestForEach()
        {
            var ret = new[] {false, false, false};

              Parallel.ForEach(new[] {0, 1, 2}, delegate(int index) {
            Assert.IsFalse(ret[index]);
            ret[index] = true;
              });

              Assert.IsTrue(ret[0]);
              Assert.IsTrue(ret[1]);
              Assert.IsTrue(ret[2]);
        }