public async Task HappyPathWithLength() { var svc = new ShortCodeGeneratorService(CoreDependenciesWithValidation.Instance); var req = new ShortCodeGeneratorRequest { Length = 8 }; var res = await svc.Execute(req, CancellationToken.None); Assert.IsTrue(res.IsSuccessful()); Assert.AreEqual(8, res.Data.Code.Length); }
public async Task HappyPathWithCustomMap() { var svc = new ShortCodeGeneratorService(CoreDependenciesWithValidation.Instance); var req = new ShortCodeGeneratorRequest { Length = 32, CustomLetterMap = "ab" }; var res = await svc.Execute(req, CancellationToken.None); Assert.IsTrue(res.IsSuccessful()); Assert.AreEqual(32, res.Data.Code.Length); Assert.AreEqual("ab", string.Join("", res.Data.Code.ToCharArray().Distinct().OrderBy(x => x).ToArray())); }
public async Task HappyPathTwoRequestsResultInDifferentCodes() { var svc = new ShortCodeGeneratorService(CoreDependenciesWithValidation.Instance); var req = new ShortCodeGeneratorRequest { Length = 4 }; var res1 = await svc.Execute(req, CancellationToken.None); var res2 = await svc.Execute(req, CancellationToken.None); Assert.IsTrue(res1.IsSuccessful()); Assert.IsTrue(res2.IsSuccessful()); Assert.AreNotEqual(res1.Data.Code, res2.Data.Code); }
public async Task HappyPathSeedGeneratesSameOutput() { var svc = new ShortCodeGeneratorService(CoreDependenciesWithValidation.Instance); var req = new ShortCodeGeneratorRequest { Length = 4, Debug = new ShortCodeGeneratorRequest.DebugData { RandomSeed = 34 } }; var res1 = await svc.Execute(req, CancellationToken.None); var res2 = await svc.Execute(req, CancellationToken.None); Assert.IsTrue(res1.IsSuccessful()); Assert.IsTrue(res2.IsSuccessful()); Assert.AreEqual("EXHY", res1.Data.Code); Assert.AreEqual(res1.Data.Code, res2.Data.Code); }