本文整理汇总了C#中DataService.PostBeer方法的典型用法代码示例。如果您正苦于以下问题:C# DataService.PostBeer方法的具体用法?C# DataService.PostBeer怎么用?C# DataService.PostBeer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataService
的用法示例。
在下文中一共展示了DataService.PostBeer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoLiveCycle
public void DoLiveCycle()
{
Task.Run(async () =>
{
//arrange
await ApiTestHelper.CreateTestUser(ApiTestHelper.TestUserGuid);
var ds = new DataService();
var beer1 = new BeerEntity()
{
Guid = Guid.NewGuid(),
DrinkTime = DateTime.Now - TimeSpan.FromDays(2)
};
var beer2 = new BeerEntity()
{
Guid = Guid.NewGuid(),
DrinkTime = DateTime.Now - TimeSpan.FromDays(1)
};
var beer3 = new BeerEntity()
{
Guid = Guid.NewGuid(),
DrinkTime = DateTime.Now
};
var add = new BeerRequest(PossibleActions.Add, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer1, beer2, beer3
}
};
var remove1 = new BeerRequest(PossibleActions.Remove, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer1, beer3
}
};
var remove2 = new BeerRequest(PossibleActions.Remove, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer2
}
};
//act
//check if 0 beers
var beers = await ds.GetBeers(ApiTestHelper.TestUserGuid);
ApiAssertHelper.CheckBaseResponse(beers);
Assert.IsTrue(beers.Beers == null || !beers.Beers.Any());
//add beers;
var res = await ds.PostBeer(add);
ApiAssertHelper.CheckBooleanResponse(res);
//check if 3 beers
beers = await ds.GetBeers(ApiTestHelper.TestUserGuid);
ApiAssertHelper.CheckBaseResponse(beers);
Assert.IsTrue(beers.Beers != null && beers.Beers.Count == 3);
//remove 2 beers;
res = await ds.PostBeer(remove1);
ApiAssertHelper.CheckBooleanResponse(res);
//check if 1 beer, check Date
beers = await ds.GetBeers(ApiTestHelper.TestUserGuid);
ApiAssertHelper.CheckBaseResponse(beers);
Assert.IsTrue(beers.Beers != null && beers.Beers.Count == 1);
Assert.IsTrue(beers.Beers[0].Guid == beer2.Guid);
Assert.IsTrue(beers.Beers[0].DrinkTime - beer2.DrinkTime < TimeSpan.FromSeconds(1));
//remove 2 invalid beers;
res = await ds.PostBeer(remove1);
ApiAssertHelper.CheckBooleanResponse(res);
//remove 1 beer left;
res = await ds.PostBeer(remove2);
ApiAssertHelper.CheckBooleanResponse(res);
//check if 0 beers
beers = await ds.GetBeers(ApiTestHelper.TestUserGuid);
ApiAssertHelper.CheckBaseResponse(beers);
Assert.IsTrue(beers.Beers == null || !beers.Beers.Any());
//clean
await ApiTestHelper.DeleteTestUser(ApiTestHelper.TestUserGuid);
}).GetAwaiter().GetResult();
}
示例2: TestSync
public void TestSync()
{
Task.Run(async () =>
{
//arrange
await ApiTestHelper.CreateTestUser(ApiTestHelper.TestUserGuid);
var ds = new DataService();
var beer1 = new BeerEntity()
{
Guid = Guid.NewGuid(),
DrinkTime = DateTime.Now - TimeSpan.FromDays(2)
};
var beer2 = new BeerEntity()
{
Guid = Guid.NewGuid(),
DrinkTime = DateTime.Now - TimeSpan.FromDays(1)
};
var beer3 = new BeerEntity()
{
Guid = Guid.NewGuid(),
DrinkTime = DateTime.Now
};
var beer4 = new BeerEntity()
{
Guid = Guid.NewGuid(),
DrinkTime = DateTime.Now + TimeSpan.FromDays(1)
};
var add = new BeerRequest(PossibleActions.Add, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer1, beer2, beer3
}
};
var remove = new BeerRequest(PossibleActions.Remove, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer1, beer3, beer2
}
};
var correct1 = new BeerRequest(PossibleActions.Sync, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer3
}
};
var correct2 = new BeerRequest(PossibleActions.Sync, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer3, beer2, beer1
}
};
var false1 = new BeerRequest(PossibleActions.Sync, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer1, beer2
}
};
var false2 = new BeerRequest(PossibleActions.Sync, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
}
};
var false3 = new BeerRequest(PossibleActions.Sync, ApiTestHelper.TestUserGuid)
{
Beers = new List<BeerEntity>()
{
beer1, beer2,beer4
}
};
var res = await ds.PostBeer(add);
ApiAssertHelper.CheckBooleanResponse(res);
//act
res = await ds.PostBeer(correct1);
ApiAssertHelper.CheckBooleanResponse(res);
res = await ds.PostBeer(correct2);
ApiAssertHelper.CheckBooleanResponse(res);
res = await ds.PostBeer(false1);
ApiAssertHelper.CheckBooleanResponseForFalse(res);
res = await ds.PostBeer(false2);
ApiAssertHelper.CheckBooleanResponseForFalse(res);
res = await ds.PostBeer(false3);
ApiAssertHelper.CheckBooleanResponseForFalse(res);
//clean
await ds.PostBeer(remove);
//.........这里部分代码省略.........