コード例 #1
0
        public void Load_WithValidFile_ExpectProperData(
            string filename,
            string data)
        {
            using (MolesContext.Create())
            {
                // Arrange
                var expectedData = data;
                var fileInfo     = new FileInfo(filename);

                MFileSystem.ReadAllTextFileInfo = info =>
                {
                    Console.WriteLine("filename: {0}", info.Name);
                    Assert.IsTrue(info.Name == filename);
                    return(data);
                };

                var classUnderTest = new Import();

                // Act
                classUnderTest.Load(fileInfo);

                // Assert
                Assert.AreEqual(expectedData, classUnderTest.Data);
            }
        }
コード例 #2
0
ファイル: ClassTest11.cs プロジェクト: didierdiaz/injection
        public void test()
        {
            int calls = 0;

            MDependency11.AllInstances.generate = (Dependency11 dependency) =>
            {
                if (++calls == 2)
                {
                    return(123);
                }

                return(MolesContext.ExecuteWithoutMoles(() =>
                {
                    return dependency.generate();
                }));
            };

            Class11 clazz = new Class11();

            Assert.AreEqual(999 + (2 * 123), clazz.generate());
        }
コード例 #3
0
        public void test()
        {
            int count = 0;

            MDependency08.AllInstances.generate = (Dependency08 dependency) =>
            {
                ++count;

                return(MolesContext.ExecuteWithoutMoles(() => {
                    return dependency.generate();
                }));
            };

            Class08 clazz = new Class08();

            for (int i = 0; i < 10; ++i)
            {
                Assert.AreEqual(2 * 999, clazz.generate());
            }

            Assert.AreEqual(10, count);
        }