public void NameIsCorrect()
        {
            var expected = Guid.NewGuid().ToString();
            var sut      = new TaskComposite(expected);

            Assert.Equal(expected, sut.Name);
        }
        public void DescriptionIsCorrect()
        {
            var expected = Guid.NewGuid().ToString();
            var sut      = new TaskComposite(arbitraryName, expected);

            Assert.Equal(expected, sut.Description);
        }
示例#3
0
 public void Visit(TaskComposite composite)
 {
     foreach (ITaskComponent component in composite)
     {
         component.Accept(this);
     }
 }
        public void CannotAddNullToComposite()
        {
            var sut = new TaskComposite(arbitraryName);

            var exception = Record.Exception(() => sut.Add(null));

            Assert.IsType <ArgumentNullException>(exception);
        }
        public void ContainsComponentInComposite1()
        {
            var component = new Mock <ITaskComponent>().Object;
            var sut       = new TaskComposite(arbitraryName, components: new List <ITaskComponent> {
                component
            });

            Assert.True(sut.Contains(component));
        }
        public void AddComponentToComposite()
        {
            var sut       = new TaskComposite(arbitraryName);
            var component = new Mock <ITaskComponent>().Object;

            sut.Add(component);

            Assert.True(sut.Any(tc => tc == component));
        }
        public void AcceptCallsVisitor()
        {
            var sut         = new TaskComposite(arbitraryName);
            var visitorStub = new Mock <ITaskVisitor>();

            sut.Accept(visitorStub.Object);

            visitorStub.Verify(v => v.Visit(sut));
        }
        public void ComponentsIsCorrect5()
        {
            var components = new List <ITaskComponent> {
                new Mock <ITaskComponent>().Object
            };
            var sut = new TaskComposite(arbitraryName, arbitraryDescription, components);

            Assert.True(sut.Count() == components.Count && sut.SequenceEqual(components));
        }
        public void ContainsComponentInComposite2()
        {
            var sut       = new TaskComposite(arbitraryName);
            var component = new Mock <ITaskComponent>().Object;

            sut.Add(component);

            Assert.True(sut.Contains(component));
        }
        public void RemoveComponentFromComposite2()
        {
            var sut       = new TaskComposite(arbitraryName);
            var component = new Mock <ITaskComponent>().Object;

            sut.Add(component);
            sut.Remove(component);

            Assert.False(sut.Any(tc => tc == component));
        }
        public void RemoveComponentFromComposite1()
        {
            var component = new Mock <ITaskComponent>().Object;
            var sut       = new TaskComposite(arbitraryName, components: new List <ITaskComponent> {
                component
            });

            sut.Remove(component);

            Assert.False(sut.Any(tc => tc == component));
        }
        public void EnumerationIsCorrect()
        {
            var components = new List <ITaskComponent> {
                new Mock <ITaskComponent>().Object, new Mock <ITaskComponent>().Object
            };
            var sut = new TaskComposite(arbitraryName, arbitraryDescription, components);

            int enumeratedCount = 0;

            foreach (var component in components)
            {
                Assert.True(components.Contains(component));
                enumeratedCount++;
            }

            Assert.True(enumeratedCount == components.Count);
        }
        public void ValueIsCorrect(decimal value1, decimal value2, decimal value3)
        {
            var expected = value1 + value2 + value3;
            var e1       = new TaskElement(arbitraryName, value1);
            var e2       = new TaskElement(arbitraryName, value2);
            var e3       = new TaskElement(arbitraryName, value3);
            var c1       = new TaskComposite(arbitraryName, components: new List <ITaskComponent> {
                e2, e3
            });
            var rootComposite = new TaskComposite(arbitraryName, components: new List <ITaskComponent> {
                e1, c1
            });
            var sut = new ValueTaskVisitor();

            rootComposite.Accept(sut);

            Assert.Equal(expected, sut.Value);
        }
        public void DescriptionDefaultValueIsEmptyString2()
        {
            var sut = new TaskComposite(arbitraryName, new List <ITaskComponent>());

            Assert.Equal(string.Empty, sut.Description);
        }
        public void DescriptionDefaultValueIsEmptyString1()
        {
            var sut = new TaskComposite(arbitraryName);

            Assert.Equal(string.Empty, sut.Description);
        }
        public void ComponentsIsCorrect1()
        {
            var sut = new TaskComposite(arbitraryName);

            Assert.False(sut.Any());
        }
        public void ComponentsIsCorrect3()
        {
            var sut = new TaskComposite(arbitraryName, components: new List <ITaskComponent>());

            Assert.False(sut.Any());
        }
        public void ComponentsIsCorrect4()
        {
            var sut = new TaskComposite(arbitraryName, arbitraryDescription, new List <ITaskComponent>());

            Assert.False(sut.Any());
        }
        public void SutIsEnumerable()
        {
            var sut = new TaskComposite(arbitraryName);

            Assert.IsAssignableFrom <IEnumerable <ITaskComponent> >(sut);
        }