コード例 #1
0
        public async Task <IActionResult> Create(PadSeriesCreateCommand create)
        {
            var id = await mediator.Dispatch <PadSeriesCreateCommand, Guid>(create, User);

            var ps = await mediator.Dispatch <GetPadSeriesByIdQuery, PadSeriesReadModel>(new(id), User);

            return(Ok(ps));
        }
コード例 #2
0
        public async Task ExecuteCreatesSizes()
        {
            var mockSpec = new Mock <PadSeriesCreateOrUpdateCompositeSpecification>(null, null, null, null, null, null);

            mockSpec.Setup(s => s.CheckAndThrow(It.IsAny <PadSeries>())).Returns(Task.FromResult(new SpecificationResult(true)));

            var mockRepo            = new Mock <IPadSeriesRepo>();
            List <PadSeries> series = new();

            mockRepo.Setup(r => r.Add(Capture.In(series)));

            var h = new PadSeriesCreateHandler(
                mockSpec.Object,
                mockRepo.Object,
                Mock.Of <IImageProcessor>()
                );

            var brandId = Guid.NewGuid();

            var c = new PadSeriesCreateCommand(
                "Name",
                brandId,
                PolisherType.DualAction,
                new PadSizeCreateOrUpdate[] {
                new PadSizeCreateOrUpdate(null, new Measurement(1.2f, "in"))
            }.ToList(),
                new PadCreateOrUpdate[] {
                new PadCreateOrUpdate(null, "Color", PadCategory.Cutting, PadMaterial.Foam, PadTexture.Dimpled, PadColor.Red, false, null, new PadOptionCreateOrUpdate[] {
                    new PadOptionCreateOrUpdate(Guid.NewGuid(), 0, new PartNumberCreateOrUpdate[] { new PartNumberCreateOrUpdate(null, "value", "NOTES") }.ToList())
                }.ToList())
            }.ToList()
                );

            var id = await h.Execute(c, null);

            Assert.AreEqual(1, series.Count);
            var s = series[0];

            Assert.AreEqual("Name", s.Name);
            Assert.AreEqual(brandId, s.BrandId);
            Assert.AreEqual(PolisherType.DualAction, s.PolisherTypes[0]);

            Assert.AreEqual(s.Sizes[0].Diameter, new Measurement(1.2f, "in"));

            Assert.AreEqual("Color", s.Pads[0].Name);
            Assert.AreEqual(PadCategory.Cutting, s.Pads[0].Category[0]);
            Assert.AreEqual(PadTexture.Dimpled, s.Pads[0].Texture);
            Assert.AreEqual(PadMaterial.Foam, s.Pads[0].Material);
            Assert.AreEqual(1, s.Pads[0].Options.Count);
            Assert.AreEqual("value", s.Pads[0].Options[0].PartNumbers[0].Value);
            Assert.AreEqual("NOTES", s.Pads[0].Options[0].PartNumbers[0].Notes);
        }
コード例 #3
0
        public async Task ExecuteOrdersColorByName()
        {
            var mockSpec = new Mock <PadSeriesCreateOrUpdateCompositeSpecification>(null, null, null, null, null, null);

            mockSpec.Setup(s => s.CheckAndThrow(It.IsAny <PadSeries>())).Returns(Task.FromResult(new SpecificationResult(true)));

            var mockRepo            = new Mock <IPadSeriesRepo>();
            List <PadSeries> series = new();

            mockRepo.Setup(r => r.Add(Capture.In(series)));

            var h = new PadSeriesCreateHandler(
                mockSpec.Object,
                mockRepo.Object,
                Mock.Of <IImageProcessor>()
                );

            var brandId = Guid.NewGuid();

            var c = new PadSeriesCreateCommand(
                "Name",
                brandId,
                PolisherType.DualAction,
                new PadSizeCreateOrUpdate[] {
                new PadSizeCreateOrUpdate(null, new Measurement(1f, "in")),
            }.ToList(),
                new PadCreateOrUpdate[] {
                new PadCreateOrUpdate(null, "B", PadCategory.Cutting, PadMaterial.Foam, PadTexture.Dimpled, PadColor.Red, false, null, new PadOptionCreateOrUpdate[] {
                    new PadOptionCreateOrUpdate(Guid.NewGuid(), 0)
                }.ToList()),
                new PadCreateOrUpdate(null, "A", PadCategory.Cutting, PadMaterial.Foam, PadTexture.Dimpled, PadColor.Red, false, null, new PadOptionCreateOrUpdate[] {
                    new PadOptionCreateOrUpdate(Guid.NewGuid(), 0)
                }.ToList()),
                new PadCreateOrUpdate(null, "C", PadCategory.Cutting, PadMaterial.Foam, PadTexture.Dimpled, PadColor.Red, false, null, new PadOptionCreateOrUpdate[] {
                    new PadOptionCreateOrUpdate(Guid.NewGuid(), 0)
                }.ToList())
            }.ToList()
                );

            await h.Execute(c, null);

            Assert.AreEqual("A", series[0].Pads[0].Name);
            Assert.AreEqual("B", series[0].Pads[1].Name);
            Assert.AreEqual("C", series[0].Pads[2].Name);
        }