public void ConstructorSetsServerPropertyCorrectly([Values(true, false)]bool serverCanModifyLastModificationDate) {
            var session = new Mock<ISession>();
            session.SetupTypeSystem(serverCanModifyLastModificationDate);
            var underTest = new SolverClass(session.Object, Mock.Of<IMetaDataStorage>());

            Assert.That(underTest.GetModification(), Is.EqualTo(serverCanModifyLastModificationDate));
        }
Exemplo n.º 2
0
        public void ConstructorSetsServerPropertyCorrectly()
        {
            var solver = new SolverClass(Mock.Of <ISession>(), Mock.Of <IMetaDataStorage>(), true);

            Assert.That(solver.GetModification(), Is.True);
            solver = new SolverClass(Mock.Of <ISession>(), Mock.Of <IMetaDataStorage>(), false);
            Assert.That(solver.GetModification(), Is.False);
        }
        public void ConstructorSetsServerPropertyCorrectly([Values(true, false)] bool serverCanModifyLastModificationDate)
        {
            var session = new Mock <ISession>();

            session.SetupTypeSystem(serverCanModifyLastModificationDate);
            var underTest = new SolverClass(session.Object, Mock.Of <IMetaDataStorage>());

            Assert.That(underTest.GetModification(), Is.EqualTo(serverCanModifyLastModificationDate));
        }
        public void EnsureLegalCharactersThrowsExceptionIfFilenameContainsUtf8Character() {
            var session = new Mock<ISession>();
            session.SetupTypeSystem();
            var underTest = new SolverClass(session.Object, Mock.Of<IMetaDataStorage>());
            var exception = new CmisConstraintException();
            var fileInfo = Mock.Of<IFileSystemInfo>(f => f.Name == @"ä" && f.FullName == @"ä");

            Assert.Throws<InteractionNeededException>(() => underTest.CallEnsureThatLocalFileNameContainsLegalCharacters(fileInfo, exception));
        }
Exemplo n.º 5
0
        public void ConstructorSetsPropertiesCorrectly()
        {
            var session = Mock.Of <ISession>();
            var storage = Mock.Of <IMetaDataStorage>();
            var solver  = new SolverClass(session, storage);

            Assert.That(solver.GetSession(), Is.EqualTo(session));
            Assert.That(solver.GetStorage(), Is.EqualTo(storage));
        }
        public void ConstructorSetsModificationPossibilityToFalse()
        {
            var session = new Mock <ISession>();

            session.SetupTypeSystem(false);
            var underTest = new SolverClass(session.Object, Mock.Of <IMetaDataStorage>());

            Assert.That(underTest.GetModification(), Is.False);
        }
        public void ConstructorSetsServerPropertyCorrectly()
        {
            var session = new Mock <ISession>();

            session.SetupTypeSystem(true);

            var underTest = new SolverClass(session.Object, Mock.Of <IMetaDataStorage>());

            Assert.That(underTest.GetModification(), Is.True);
        }
        public void EnsureLegalCharactersIfFilenameIsValid()
        {
            var session = new Mock <ISession>();

            session.SetupTypeSystem();
            var underTest = new SolverClass(session.Object, Mock.Of <IMetaDataStorage>());
            var exception = new CmisConstraintException();
            var fileInfo  = Mock.Of <IFileSystemInfo>(f => f.Name == "foo");

            underTest.CallEnsureThatLocalFileNameContainsLegalCharacters(fileInfo, exception);
        }
        public void UploadFileClosesTransmissionOnIOException()
        {
            var session = new Mock <ISession>();

            session.SetupTypeSystem();

            var underTest = new SolverClass(session.Object, Mock.Of <IMetaDataStorage>());

            underTest.Upload(null, null, null);
            Assert.Fail("TODO");
        }
        public void ConstructorSetsPropertiesCorrectly([Values(true, false)]bool withGivenTransmissionStorage) {
            var session = new Mock<ISession>();
            session.SetupTypeSystem();
            var storage = Mock.Of<IMetaDataStorage>();
            var transmissionStorage = withGivenTransmissionStorage ? Mock.Of<IFileTransmissionStorage>() : null;
            var underTest = new SolverClass(session.Object, storage, transmissionStorage);

            Assert.That(underTest.GetSession(), Is.EqualTo(session.Object));
            Assert.That(underTest.GetStorage(), Is.EqualTo(storage));
            Assert.That(underTest.GetTransmissionStorage(), Is.EqualTo(transmissionStorage));
        }
        public void EnsureLegalCharactersThrowsExceptionIfFilenameContainsUtf8Character()
        {
            var session = new Mock <ISession>();

            session.SetupTypeSystem();
            var underTest = new SolverClass(session.Object, Mock.Of <IMetaDataStorage>());
            var exception = new CmisConstraintException();
            var fileInfo  = Mock.Of <IFileSystemInfo>(f => f.Name == @"ä" && f.FullName == @"ä");

            Assert.Throws <InteractionNeededException>(() => underTest.CallEnsureThatLocalFileNameContainsLegalCharacters(fileInfo, exception));
        }
        public void ConstructorSetsPropertiesCorrectly()
        {
            var session = new Mock <ISession>();

            session.SetupTypeSystem();
            var storage = Mock.Of <IMetaDataStorage>();

            var underTest = new SolverClass(session.Object, storage);

            Assert.That(underTest.GetSession(), Is.EqualTo(session.Object));
            Assert.That(underTest.GetStorage(), Is.EqualTo(storage));
        }
        public void ConstructorSetsPropertiesCorrectly([Values(true, false)] bool withGivenTransmissionStorage)
        {
            var session = new Mock <ISession>();

            session.SetupTypeSystem();
            var storage             = Mock.Of <IMetaDataStorage>();
            var transmissionStorage = withGivenTransmissionStorage ? Mock.Of <IFileTransmissionStorage>() : null;
            var underTest           = new SolverClass(session.Object, storage, transmissionStorage);

            Assert.That(underTest.GetSession(), Is.EqualTo(session.Object));
            Assert.That(underTest.GetStorage(), Is.EqualTo(storage));
            Assert.That(underTest.GetTransmissionStorage(), Is.EqualTo(transmissionStorage));
        }
Exemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        //		string m = "1000000011100001100100000000000010100000011000001000010001110010";//8x8
        string m = "001101110010010100101100001000000010";        //6x6
//		string m = "1110000101100100";//4x4
        SolverBoard b = new SolverBoard(m);

        Debug.Log(b.ToString());

        SolverClass solver = new SolverClass(m);
//		List<Thread> threads = new List<Thread>();

        List <SolverClass> solvers = new List <SolverClass>();

        ManualResetEvent[] doneEvents = new ManualResetEvent[m.Length];


        int ac = 0;

        for (int x = 0; x < solver.length; ++x)
        {
            for (int y = 0; y < solver.length; ++y)
            {
                b.ApplyMove(x, y);

                doneEvents[ac] = new ManualResetEvent(false);

                solvers.Add(new SolverClass(b.matrix_str, doneEvents[ac]));

//				threads.Add(new Thread(() => solvers[solvers.Count-1].Solve()));

                ThreadPool.QueueUserWorkItem((object a) => solvers[solvers.Count - 1].Solve(0));

                ac++;
            }
        }

        bool waitALittleMore = false;

        int min = 1000000;

        do
        {
            WaitHandle.WaitAll(doneEvents);

            for (int i = 0; i < solvers.Count; ++i)
            {
                if (solvers[i].solved)
                {
                    if (solvers[i].minMoves < min)
                    {
                        min = solvers[i].minMoves;
//						solvers[i].
                    }
                }
            }

            waitALittleMore = false;

            for (int i = 0; i < solvers.Count && !waitALittleMore; ++i)
            {
                if (solvers[i].statesByLevel.Count - 1 < min)
                {
                    waitALittleMore = true;
                }
            }
        }while(waitALittleMore);

        for (int i = 0; i < solvers.Count; ++i)
        {
            solvers[i].externalSolved = true;
        }

        Debug.Log("Ended");
        Debug.Log("Min = " + min);
    }
Exemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        //		string m = "1000000011100001100100000000000010100000011000001000010001110010";//8x8
        string m = "001101110010010100101100001000000010";//6x6
        //		string m = "1110000101100100";//4x4
        SolverBoard b = new SolverBoard(m);

        Debug.Log(b.ToString());

        SolverClass solver = new SolverClass(m);
        //		List<Thread> threads = new List<Thread>();

        List<SolverClass> solvers = new List<SolverClass>();
        ManualResetEvent[] doneEvents = new ManualResetEvent[m.Length];

        int ac = 0;
        for(int x = 0 ; x < solver.length ; ++x){
            for(int y = 0 ; y < solver.length ; ++y){
                b.ApplyMove(x,y);

                doneEvents[ac] = new ManualResetEvent(false);

                solvers.Add(new SolverClass(b.matrix_str, doneEvents[ac]));

        //				threads.Add(new Thread(() => solvers[solvers.Count-1].Solve()));

                ThreadPool.QueueUserWorkItem((object a)=>solvers[solvers.Count-1].Solve(0));

                ac++;
            }
        }

        bool waitALittleMore = false;

        int min = 1000000;

        do{
            WaitHandle.WaitAll(doneEvents);

            for(int i = 0 ; i < solvers.Count ; ++i){
                if(solvers[i].solved){
                    if(solvers[i].minMoves < min){
                        min = solvers[i].minMoves;
        //						solvers[i].
                    }
                }
            }

            waitALittleMore = false;

            for(int i = 0 ; i < solvers.Count && !waitALittleMore ; ++i){
                if(solvers[i].statesByLevel.Count -1 < min){
                    waitALittleMore = true;
                }
            }
        }while(waitALittleMore);

        for(int i = 0 ; i < solvers.Count ; ++i){
            solvers[i].externalSolved = true;
        }

        Debug.Log("Ended");
        Debug.Log("Min = " + min);
    }
        public void UploadFileClosesTransmissionOnIOException() {
            var session = new Mock<ISession>();
            session.SetupTypeSystem();

            var underTest = new SolverClass(session.Object, Mock.Of<IMetaDataStorage>());

            underTest.Upload(null, null, null);
            Assert.Fail("TODO");
        }
        public void EnsureLegalCharactersIfFilenameIsValid() {
            var session = new Mock<ISession>();
            session.SetupTypeSystem();
            var underTest = new SolverClass(session.Object, Mock.Of<IMetaDataStorage>());
            var exception = new CmisConstraintException();
            var fileInfo = Mock.Of<IFileSystemInfo>(f => f.Name == "foo");

            underTest.CallEnsureThatLocalFileNameContainsLegalCharacters(fileInfo, exception);
        }