Exemplo n.º 1
0
        public void AddGroup_ShouldReturn_Success()
        {
            // Arrange
            GroupsModel group = new GroupsModel()
            {
                Name               = "Group 1",
                Number             = "1",
                Identifier         = "_1",
                AncestorNumber     = "2",
                AncestorIdentifier = "_2",
                ProductType        = "r",
                Link               = "some link",
                Notes              = "some notes"
            };

            fakeGroupsRepository.Setup(a => a.Add(group));
            groupsService = new GroupsService(fakeGroupsRepository.Object);
            GroupsDtoModel groupDto = new GroupsDtoModel()
            {
                Name               = group.Name,
                Number             = group.Number,
                Identifier         = group.Identifier,
                AncestorNumber     = group.AncestorNumber,
                AncestorIdentifier = group.AncestorIdentifier,
                ProductType        = group.ProductType,
                Link               = group.Link,
                Notes              = group.Notes
            };

            try
            {
                // Act
                groupsService.AddGroup(groupDto);
                operationSucceeded = true;
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message + " | " + ex.StackTrace;
            }

            // Assert
            Assert.IsTrue(operationSucceeded, errorMessage);
        }
Exemplo n.º 2
0
 public void Post([FromBody] GroupModel value)
 {
     _groups.AddGroup(value);
 }