Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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()));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        public void NoErrorCodesDefined()
        {
            var svc = new ShortCodeGeneratorService(CoreDependenciesWithValidation.Instance);

            Assert.AreEqual(0, svc.AllErrorCodes().Count());
        }